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 | * |
| 10 | * Copyright (C) 2002 by Björn Stenberg |
| 11 | * |
| 12 | * All files in this archive are subject to the GNU General Public License. |
| 13 | * See the file COPYING in the source tree root for full license agreement. |
| 14 | * |
| 15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 16 | * KIND, either express or implied. |
| 17 | * |
| 18 | ****************************************************************************/ |
Linus Nielsen Feltzing | 688b4dd | 2004-10-15 02:16:31 +0000 | [diff] [blame] | 19 | #include "config.h" |
| 20 | |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 21 | #include "ata.h" |
| 22 | #include "disk.h" |
| 23 | #include "fat.h" |
| 24 | #include "lcd.h" |
Linus Nielsen Feltzing | 9b3a3be | 2002-06-24 13:51:40 +0000 | [diff] [blame] | 25 | #include "rtc.h" |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 26 | #include "debug.h" |
| 27 | #include "led.h" |
| 28 | #include "kernel.h" |
| 29 | #include "button.h" |
Björn Stenberg | 8218285 | 2002-05-16 12:53:40 +0000 | [diff] [blame] | 30 | #include "tree.h" |
Björn Stenberg | 55c7da2 | 2002-05-21 14:28:10 +0000 | [diff] [blame] | 31 | #include "panic.h" |
| 32 | #include "menu.h" |
Linus Nielsen Feltzing | 0f60775 | 2002-05-29 09:14:38 +0000 | [diff] [blame] | 33 | #include "system.h" |
Linus Nielsen Feltzing | 6c77cc3 | 2002-06-30 13:24:29 +0000 | [diff] [blame] | 34 | #include "usb.h" |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 35 | #include "powermgmt.h" |
Linus Nielsen Feltzing | 7d3c31b | 2002-06-30 20:25:37 +0000 | [diff] [blame] | 36 | #include "adc.h" |
Linus Nielsen Feltzing | 6d2e492 | 2002-07-02 21:40:12 +0000 | [diff] [blame] | 37 | #include "i2c.h" |
Björn Stenberg | 18239b8 | 2002-08-12 12:44:18 +0000 | [diff] [blame] | 38 | #ifndef DEBUG |
| 39 | #include "serial.h" |
| 40 | #endif |
Linus Nielsen Feltzing | 8a237a8 | 2005-04-04 12:06:29 +0000 | [diff] [blame] | 41 | #include "audio.h" |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 42 | #include "mp3_playback.h" |
Björn Stenberg | 3ed2874 | 2002-05-24 15:51:39 +0000 | [diff] [blame] | 43 | #include "main_menu.h" |
Felix Arends | e096c86 | 2002-06-12 15:31:35 +0000 | [diff] [blame] | 44 | #include "thread.h" |
Linus Nielsen Feltzing | 31e2097 | 2002-06-20 08:59:54 +0000 | [diff] [blame] | 45 | #include "settings.h" |
Linus Nielsen Feltzing | 9b3a3be | 2002-06-24 13:51:40 +0000 | [diff] [blame] | 46 | #include "backlight.h" |
Linus Nielsen Feltzing | 97f94b4 | 2002-07-22 22:44:03 +0000 | [diff] [blame] | 47 | #include "status.h" |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 48 | #include "debug_menu.h" |
Daniel Stenberg | 7b71911 | 2002-05-29 10:05:27 +0000 | [diff] [blame] | 49 | #include "version.h" |
Linus Nielsen Feltzing | 6c77cc3 | 2002-06-30 13:24:29 +0000 | [diff] [blame] | 50 | #include "sprintf.h" |
Daniel Stenberg | 93b231c | 2002-09-12 13:33:59 +0000 | [diff] [blame] | 51 | #include "font.h" |
Daniel Stenberg | 5b662ff | 2002-09-25 11:42:10 +0000 | [diff] [blame] | 52 | #include "language.h" |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 53 | #include "wps-display.h" |
Björn Stenberg | 7bb746b | 2003-04-24 17:31:36 +0000 | [diff] [blame] | 54 | #include "playlist.h" |
Linus Nielsen Feltzing | 20d031f | 2003-05-09 16:01:21 +0000 | [diff] [blame] | 55 | #include "buffer.h" |
Jörg Hohensohn | c47f8c0 | 2003-07-03 22:13:39 +0000 | [diff] [blame] | 56 | #include "rolo.h" |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 57 | #include "screens.h" |
| 58 | #include "power.h" |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 59 | #include "talk.h" |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 60 | #include "plugin.h" |
Linus Nielsen Feltzing | 3d21781 | 2005-04-06 11:12:22 +0000 | [diff] [blame] | 61 | #include "misc.h" |
Michiel Van Der Kolk | 10b2069 | 2005-07-01 18:01:23 +0000 | [diff] [blame] | 62 | #include "database.h" |
Michiel Van Der Kolk | 451dd48 | 2005-03-28 00:00:24 +0000 | [diff] [blame] | 63 | |
Henrik Backe | c1a951f | 2005-03-28 13:00:22 +0000 | [diff] [blame] | 64 | #if (CONFIG_HWCODEC == MASNONE) |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 65 | #include "pcmbuf.h" |
Daniel Stenberg | 771ed79 | 2005-07-14 21:32:56 +0000 | [diff] [blame] | 66 | #else |
| 67 | #define pcmbuf_init() |
Henrik Backe | c1a951f | 2005-03-28 13:00:22 +0000 | [diff] [blame] | 68 | #endif |
Linus Nielsen Feltzing | 52d5b30 | 2005-07-09 08:05:04 +0000 | [diff] [blame] | 69 | #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR) |
Andy | e5d0872 | 2005-06-19 03:05:53 +0000 | [diff] [blame] | 70 | #include "pcm_record.h" |
| 71 | #endif |
Michiel Van Der Kolk | 451dd48 | 2005-03-28 00:00:24 +0000 | [diff] [blame] | 72 | |
Jörg Hohensohn | 4a5df8e | 2004-10-15 22:10:55 +0000 | [diff] [blame] | 73 | #ifdef CONFIG_TUNER |
Jörg Hohensohn | 8f8fbac | 2004-10-15 21:41:46 +0000 | [diff] [blame] | 74 | #include "radio.h" |
Jörg Hohensohn | 4a5df8e | 2004-10-15 22:10:55 +0000 | [diff] [blame] | 75 | #endif |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 76 | #ifdef HAVE_MMC |
| 77 | #include "ata_mmc.h" |
| 78 | #endif |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 79 | |
Christian Gmeiner | 7c1879b | 2005-04-15 12:08:49 +0000 | [diff] [blame] | 80 | #ifdef HAVE_REMOTE_LCD |
| 81 | #include "lcd-remote.h" |
| 82 | #endif |
| 83 | |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 84 | /*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */ |
Björn Stenberg | 18239b8 | 2002-08-12 12:44:18 +0000 | [diff] [blame] | 85 | |
Jens Arnold | abe77a1 | 2004-08-01 21:50:57 +0000 | [diff] [blame] | 86 | const char appsversion[]=APPSVERSION; |
Daniel Stenberg | 7b71911 | 2002-05-29 10:05:27 +0000 | [diff] [blame] | 87 | |
Felix Arends | e096c86 | 2002-06-12 15:31:35 +0000 | [diff] [blame] | 88 | void init(void); |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 89 | |
Björn Stenberg | 55c7da2 | 2002-05-21 14:28:10 +0000 | [diff] [blame] | 90 | void app_main(void) |
| 91 | { |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 92 | init(); |
Björn Stenberg | 55c7da2 | 2002-05-21 14:28:10 +0000 | [diff] [blame] | 93 | browse_root(); |
| 94 | } |
| 95 | |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 96 | #ifdef SIMULATOR |
| 97 | |
Felix Arends | e096c86 | 2002-06-12 15:31:35 +0000 | [diff] [blame] | 98 | void init(void) |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 99 | { |
| 100 | init_threads(); |
Linus Nielsen Feltzing | 20d031f | 2003-05-09 16:01:21 +0000 | [diff] [blame] | 101 | buffer_init(); |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 102 | lcd_init(); |
Jens Arnold | 3a5bd7a | 2005-07-07 21:03:58 +0000 | [diff] [blame] | 103 | #ifdef HAVE_REMOTE_LCD |
| 104 | lcd_remote_init(); |
| 105 | #endif |
Kjell Ericson | fd9f864 | 2002-10-28 19:52:22 +0000 | [diff] [blame] | 106 | font_init(); |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 107 | show_logo(); |
Jens Arnold | 0f04029 | 2005-01-19 21:43:15 +0000 | [diff] [blame] | 108 | lang_init(); |
Miika Pekkarinen | f090dc3 | 2005-07-21 11:44:00 +0000 | [diff] [blame] | 109 | audio_init(); |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 110 | settings_reset(); |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 111 | settings_calc_config_sector(); |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 112 | settings_load(SETTINGS_ALL); |
| 113 | settings_apply(); |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 114 | sleep(HZ/2); |
Daniel Stenberg | b85f103 | 2003-05-14 06:38:17 +0000 | [diff] [blame] | 115 | tree_init(); |
Linus Nielsen Feltzing | fe6cf2d | 2003-05-17 22:25:52 +0000 | [diff] [blame] | 116 | playlist_init(); |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 117 | mp3_init( global_settings.volume, |
| 118 | global_settings.bass, |
| 119 | global_settings.treble, |
| 120 | global_settings.balance, |
| 121 | global_settings.loudness, |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 122 | global_settings.avc, |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 123 | global_settings.channel_config, |
Jens Arnold | 76b257f | 2005-01-12 00:24:15 +0000 | [diff] [blame] | 124 | global_settings.stereo_width, |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 125 | global_settings.mdb_strength, |
| 126 | global_settings.mdb_harmonics, |
| 127 | global_settings.mdb_center, |
| 128 | global_settings.mdb_shape, |
| 129 | global_settings.mdb_enable, |
| 130 | global_settings.superbass); |
Jens Arnold | 3c348df | 2005-01-26 22:48:25 +0000 | [diff] [blame] | 131 | button_clear_queue(); /* Empty the keyboard buffer */ |
Miika Pekkarinen | 159c52d | 2005-08-20 11:13:19 +0000 | [diff] [blame^] | 132 | #if CONFIG_HWCODEC == MASNONE |
| 133 | talk_init(); |
| 134 | #endif |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | #else |
Björn Stenberg | 88f7fb0 | 2002-05-24 15:40:14 +0000 | [diff] [blame] | 138 | |
Daniel Stenberg | 6682c03 | 2002-06-12 18:00:32 +0000 | [diff] [blame] | 139 | void init(void) |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 140 | { |
Jörg Hohensohn | 7ee03d0 | 2004-12-29 22:33:32 +0000 | [diff] [blame] | 141 | int rc; |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 142 | bool mounted = false; |
Daniel Stenberg | 8ef88a1 | 2005-02-03 08:36:43 +0000 | [diff] [blame] | 143 | #if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034) |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 144 | /* if nobody initialized ATA before, I consider this a cold start */ |
| 145 | bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */ |
Daniel Stenberg | 8ef88a1 | 2005-02-03 08:36:43 +0000 | [diff] [blame] | 146 | #endif |
Linus Nielsen Feltzing | 0f60775 | 2002-05-29 09:14:38 +0000 | [diff] [blame] | 147 | system_init(); |
Linus Nielsen Feltzing | 8c00b4c | 2002-06-10 14:44:15 +0000 | [diff] [blame] | 148 | kernel_init(); |
Linus Nielsen Feltzing | 31e2097 | 2002-06-20 08:59:54 +0000 | [diff] [blame] | 149 | |
Linus Nielsen Feltzing | e7b993f | 2005-03-18 11:38:15 +0000 | [diff] [blame] | 150 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
| 151 | set_cpu_frequency(CPUFREQ_NORMAL); |
| 152 | #endif |
| 153 | |
Linus Nielsen Feltzing | 20d031f | 2003-05-09 16:01:21 +0000 | [diff] [blame] | 154 | buffer_init(); |
| 155 | |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 156 | settings_reset(); |
Linus Nielsen Feltzing | 0f60775 | 2002-05-29 09:14:38 +0000 | [diff] [blame] | 157 | |
Björn Stenberg | 4afa709 | 2002-05-30 12:17:18 +0000 | [diff] [blame] | 158 | lcd_init(); |
Jens Arnold | 3a5bd7a | 2005-07-07 21:03:58 +0000 | [diff] [blame] | 159 | #ifdef HAVE_REMOTE_LCD |
Christian Gmeiner | 7c1879b | 2005-04-15 12:08:49 +0000 | [diff] [blame] | 160 | lcd_remote_init(); |
| 161 | #endif |
Björn Stenberg | bed3d3f | 2002-09-20 08:07:51 +0000 | [diff] [blame] | 162 | font_init(); |
Daniel Stenberg | 75e09a8 | 2002-06-11 08:24:33 +0000 | [diff] [blame] | 163 | show_logo(); |
Jens Arnold | 0f04029 | 2005-01-19 21:43:15 +0000 | [diff] [blame] | 164 | lang_init(); |
Daniel Stenberg | 75e09a8 | 2002-06-11 08:24:33 +0000 | [diff] [blame] | 165 | |
Björn Stenberg | c4d8d97 | 2003-02-14 09:44:34 +0000 | [diff] [blame] | 166 | set_irq_level(0); |
Björn Stenberg | f43b27a | 2002-05-27 09:53:28 +0000 | [diff] [blame] | 167 | #ifdef DEBUG |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 168 | debug_init(); |
Björn Stenberg | 18239b8 | 2002-08-12 12:44:18 +0000 | [diff] [blame] | 169 | #else |
Jens Arnold | 2d875f8 | 2004-09-20 22:15:35 +0000 | [diff] [blame] | 170 | #ifndef HAVE_MMC /* FIXME: This is also necessary for debug builds |
| 171 | * (do debug builds on the Ondio make sense?) */ |
Björn Stenberg | 18239b8 | 2002-08-12 12:44:18 +0000 | [diff] [blame] | 172 | serial_setup(); |
Björn Stenberg | f43b27a | 2002-05-27 09:53:28 +0000 | [diff] [blame] | 173 | #endif |
Jens Arnold | 2d875f8 | 2004-09-20 22:15:35 +0000 | [diff] [blame] | 174 | #endif |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 175 | |
Linus Nielsen Feltzing | 6d2e492 | 2002-07-02 21:40:12 +0000 | [diff] [blame] | 176 | i2c_init(); |
Linus Nielsen Feltzing | 76759e0 | 2002-08-06 08:14:08 +0000 | [diff] [blame] | 177 | |
| 178 | #ifdef HAVE_RTC |
| 179 | rtc_init(); |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 180 | settings_load(SETTINGS_RTC); /* early load parts of global_settings */ |
Linus Nielsen Feltzing | 76759e0 | 2002-08-06 08:14:08 +0000 | [diff] [blame] | 181 | #endif |
| 182 | |
Linus Nielsen Feltzing | 7d3c31b | 2002-06-30 20:25:37 +0000 | [diff] [blame] | 183 | adc_init(); |
| 184 | |
Linus Nielsen Feltzing | 6c77cc3 | 2002-06-30 13:24:29 +0000 | [diff] [blame] | 185 | usb_init(); |
| 186 | |
Linus Nielsen Feltzing | 9b3a3be | 2002-06-24 13:51:40 +0000 | [diff] [blame] | 187 | backlight_init(); |
| 188 | |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 189 | button_init(); |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 190 | |
Linus Nielsen Feltzing | 53ee344 | 2003-08-25 08:57:49 +0000 | [diff] [blame] | 191 | powermgmt_init(); |
Jörg Hohensohn | 020352c | 2003-07-18 21:58:28 +0000 | [diff] [blame] | 192 | |
Jörg Hohensohn | ef8d508 | 2004-10-19 08:20:38 +0000 | [diff] [blame] | 193 | #ifdef CONFIG_TUNER |
| 194 | radio_init(); |
| 195 | #endif |
| 196 | |
Daniel Stenberg | 8ef88a1 | 2005-02-03 08:36:43 +0000 | [diff] [blame] | 197 | #if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034) |
Jens Arnold | 7197edd | 2004-12-16 22:31:26 +0000 | [diff] [blame] | 198 | if (coldstart && charger_inserted() |
| 199 | && !global_settings.car_adapter_mode |
| 200 | #ifdef ATA_POWER_PLAYERSTYLE |
| 201 | && !ide_powered() /* relies on probing result from bootloader */ |
| 202 | #endif |
| 203 | ) |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 204 | { |
| 205 | rc = charging_screen(); /* display a "charging" screen */ |
Jens Arnold | 7c7dd43 | 2005-07-11 19:14:26 +0000 | [diff] [blame] | 206 | if (rc == 1) /* charger removed */ |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 207 | power_off(); |
| 208 | /* "On" pressed or USB connected: proceed */ |
Jens Arnold | 67b17e1 | 2004-11-21 09:29:51 +0000 | [diff] [blame] | 209 | show_logo(); /* again, to provide better visual feedback */ |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 210 | } |
Daniel Stenberg | 8e43ccb | 2003-12-12 13:34:27 +0000 | [diff] [blame] | 211 | #endif |
Jörg Hohensohn | c47f8c0 | 2003-07-03 22:13:39 +0000 | [diff] [blame] | 212 | |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 213 | rc = ata_init(); |
Linus Nielsen Feltzing | 71ef31a | 2002-07-02 18:01:31 +0000 | [diff] [blame] | 214 | if(rc) |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 215 | { |
Björn Stenberg | b47e64e | 2002-08-08 20:44:25 +0000 | [diff] [blame] | 216 | #ifdef HAVE_LCD_BITMAP |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 217 | char str[32]; |
| 218 | lcd_clear_display(); |
| 219 | snprintf(str, 31, "ATA error: %d", rc); |
| 220 | lcd_puts(0, 1, str); |
| 221 | lcd_puts(0, 3, "Press ON to debug"); |
| 222 | lcd_update(); |
Björn Stenberg | 6c33c51 | 2004-09-19 21:58:37 +0000 | [diff] [blame] | 223 | while(!(button_get(true) & BUTTON_REL)); |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 224 | dbg_ports(); |
| 225 | #endif |
| 226 | panicf("ata: %d", rc); |
| 227 | } |
Jens Arnold | 2d875f8 | 2004-09-20 22:15:35 +0000 | [diff] [blame] | 228 | |
Linus Nielsen Feltzing | e85acf1 | 2004-05-21 21:49:04 +0000 | [diff] [blame] | 229 | usb_start_monitoring(); |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 230 | while (usb_detect()) |
| 231 | { /* enter USB mode early, before trying to mount */ |
| 232 | if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED) |
| 233 | #ifdef HAVE_MMC |
| 234 | if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED)) |
Linus Nielsen Feltzing | 15124aa | 2004-07-05 22:13:20 +0000 | [diff] [blame] | 235 | #endif |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 236 | { |
| 237 | usb_screen(); |
| 238 | mounted = true; /* mounting done @ end of USB mode */ |
| 239 | } |
Jens Arnold | 97a8049 | 2005-06-23 02:18:29 +0000 | [diff] [blame] | 240 | #ifdef HAVE_USB_POWER |
| 241 | if (usb_powered()) /* avoid deadlock */ |
| 242 | break; |
| 243 | #endif |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | if (!mounted) |
| 247 | { |
| 248 | rc = disk_mount_all(); |
| 249 | if (rc<=0) |
| 250 | { |
| 251 | lcd_clear_display(); |
| 252 | lcd_puts(0, 0, "No partition"); |
| 253 | lcd_puts(0, 1, "found."); |
| 254 | #ifdef HAVE_LCD_BITMAP |
| 255 | lcd_puts(0, 2, "Insert USB cable"); |
| 256 | lcd_puts(0, 3, "and fix it."); |
| 257 | lcd_update(); |
| 258 | #endif |
| 259 | while(button_get(true) != SYS_USB_CONNECTED) {}; |
| 260 | usb_screen(); |
| 261 | system_reboot(); |
| 262 | } |
Linus Nielsen Feltzing | 15124aa | 2004-07-05 22:13:20 +0000 | [diff] [blame] | 263 | } |
Björn Stenberg | de943a5 | 2002-07-15 15:06:45 +0000 | [diff] [blame] | 264 | |
Miika Pekkarinen | f090dc3 | 2005-07-21 11:44:00 +0000 | [diff] [blame] | 265 | /* On software codec platforms we have to init audio before |
| 266 | calling audio_set_buffer_margin(). */ |
| 267 | #if (CONFIG_HWCODEC == MASNONE) |
| 268 | audio_init(); |
| 269 | #endif |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 270 | settings_calc_config_sector(); |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 271 | settings_load(SETTINGS_ALL); |
| 272 | settings_apply(); |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 273 | |
Linus Nielsen Feltzing | 20d031f | 2003-05-09 16:01:21 +0000 | [diff] [blame] | 274 | status_init(); |
Jens Arnold | 3605600 | 2004-09-29 21:41:10 +0000 | [diff] [blame] | 275 | playlist_init(); |
Linus Nielsen Feltzing | 20d031f | 2003-05-09 16:01:21 +0000 | [diff] [blame] | 276 | tree_init(); |
Michiel Van Der Kolk | d6ab723 | 2005-07-04 22:10:42 +0000 | [diff] [blame] | 277 | |
Linus Nielsen Feltzing | 67bea32 | 2003-05-17 20:38:38 +0000 | [diff] [blame] | 278 | /* 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] | 279 | 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] | 280 | mp3_init( global_settings.volume, |
| 281 | global_settings.bass, |
| 282 | global_settings.treble, |
| 283 | global_settings.balance, |
| 284 | global_settings.loudness, |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 285 | global_settings.avc, |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 286 | global_settings.channel_config, |
Jens Arnold | 76b257f | 2005-01-12 00:24:15 +0000 | [diff] [blame] | 287 | global_settings.stereo_width, |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 288 | global_settings.mdb_strength, |
| 289 | global_settings.mdb_harmonics, |
| 290 | global_settings.mdb_center, |
| 291 | global_settings.mdb_shape, |
| 292 | global_settings.mdb_enable, |
| 293 | global_settings.superbass); |
Jens Arnold | 6514435 | 2005-06-20 10:04:16 +0000 | [diff] [blame] | 294 | #if (CONFIG_HWCODEC == MASNONE) |
Jens Arnold | 6514435 | 2005-06-20 10:04:16 +0000 | [diff] [blame] | 295 | sound_settings_apply(); |
Miika Pekkarinen | f090dc3 | 2005-07-21 11:44:00 +0000 | [diff] [blame] | 296 | #else |
| 297 | audio_init(); |
Jens Arnold | 6514435 | 2005-06-20 10:04:16 +0000 | [diff] [blame] | 298 | #endif |
Linus Nielsen Feltzing | 52d5b30 | 2005-07-09 08:05:04 +0000 | [diff] [blame] | 299 | #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR) |
Jens Arnold | 6514435 | 2005-06-20 10:04:16 +0000 | [diff] [blame] | 300 | pcm_init_recording(); |
| 301 | #endif |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 302 | talk_init(); |
Michiel Van Der Kolk | d6ab723 | 2005-07-04 22:10:42 +0000 | [diff] [blame] | 303 | /* runtime database has to be initialized after audio_init() */ |
| 304 | rundb_init(); |
Jens Arnold | 3a5bd7a | 2005-07-07 21:03:58 +0000 | [diff] [blame] | 305 | |
Linus Nielsen Feltzing | 67bea32 | 2003-05-17 20:38:38 +0000 | [diff] [blame] | 306 | |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 307 | #ifdef AUTOROCK |
Jens Arnold | 5690f78 | 2005-06-04 23:15:52 +0000 | [diff] [blame] | 308 | { |
Jörg Hohensohn | c47f8c0 | 2003-07-03 22:13:39 +0000 | [diff] [blame] | 309 | int fd; |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 310 | static const char filename[] = PLUGIN_DIR "/autostart.rock"; |
| 311 | |
Jörg Hohensohn | c47f8c0 | 2003-07-03 22:13:39 +0000 | [diff] [blame] | 312 | fd = open(filename, O_RDONLY); |
Jörg Hohensohn | 1b4e309 | 2005-06-22 06:11:51 +0000 | [diff] [blame] | 313 | if(fd >= 0) /* no complaint if it doesn't exist */ |
Jörg Hohensohn | c47f8c0 | 2003-07-03 22:13:39 +0000 | [diff] [blame] | 314 | { |
| 315 | close(fd); |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 316 | plugin_load((char*)filename, NULL); /* start if it does */ |
Jörg Hohensohn | c47f8c0 | 2003-07-03 22:13:39 +0000 | [diff] [blame] | 317 | } |
| 318 | } |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 319 | #endif /* #ifdef AUTOROCK */ |
Michiel Van Der Kolk | 451dd48 | 2005-03-28 00:00:24 +0000 | [diff] [blame] | 320 | |
Linus Nielsen Feltzing | 3d21781 | 2005-04-06 11:12:22 +0000 | [diff] [blame] | 321 | #ifdef HAVE_CHARGING |
| 322 | car_adapter_mode_init(); |
| 323 | #endif |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 324 | } |
| 325 | |
Björn Stenberg | 8218285 | 2002-05-16 12:53:40 +0000 | [diff] [blame] | 326 | int main(void) |
| 327 | { |
Björn Stenberg | 55c7da2 | 2002-05-21 14:28:10 +0000 | [diff] [blame] | 328 | app_main(); |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 329 | |
| 330 | while(1) { |
Jens Arnold | 5690f78 | 2005-06-04 23:15:52 +0000 | [diff] [blame] | 331 | #if CONFIG_LED == LED_REAL |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 332 | led(true); sleep(HZ/10); |
| 333 | led(false); sleep(HZ/10); |
Jens Arnold | 5690f78 | 2005-06-04 23:15:52 +0000 | [diff] [blame] | 334 | #endif |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 335 | } |
Björn Stenberg | 8218285 | 2002-05-16 12:53:40 +0000 | [diff] [blame] | 336 | return 0; |
| 337 | } |
Björn Stenberg | 55c7da2 | 2002-05-21 14:28:10 +0000 | [diff] [blame] | 338 | #endif |
Daniel Stenberg | 8ef88a1 | 2005-02-03 08:36:43 +0000 | [diff] [blame] | 339 | |