1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Björn Stenberg
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
35 #include "powermgmt.h"
42 #include "mp3_playback.h"
43 #include "main_menu.h"
46 #include "backlight.h"
48 #include "debug_menu.h"
53 #include "wps-display.h"
64 #if (CONFIG_HWCODEC == MASNONE)
69 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
70 #include "pcm_record.h"
80 #ifdef HAVE_REMOTE_LCD
81 #include "lcd-remote.h"
84 /*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
86 const char appsversion
[]=APPSVERSION
;
103 #ifdef HAVE_REMOTE_LCD
111 settings_calc_config_sector();
112 settings_load(SETTINGS_ALL
);
117 mp3_init( global_settings
.volume
,
118 global_settings
.bass
,
119 global_settings
.treble
,
120 global_settings
.balance
,
121 global_settings
.loudness
,
123 global_settings
.channel_config
,
124 global_settings
.stereo_width
,
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
);
131 button_clear_queue(); /* Empty the keyboard buffer */
139 bool mounted
= false;
140 #if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
141 /* if nobody initialized ATA before, I consider this a cold start */
142 bool coldstart
= (PACR2
& 0x4000) != 0; /* starting from Flash */
147 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
148 set_cpu_frequency(CPUFREQ_NORMAL
);
156 #ifdef HAVE_REMOTE_LCD
167 #ifndef HAVE_MMC /* FIXME: This is also necessary for debug builds
168 * (do debug builds on the Ondio make sense?) */
177 settings_load(SETTINGS_RTC
); /* early load parts of global_settings */
194 #if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
195 if (coldstart
&& charger_inserted()
196 && !global_settings
.car_adapter_mode
197 #ifdef ATA_POWER_PLAYERSTYLE
198 && !ide_powered() /* relies on probing result from bootloader */
202 rc
= charging_screen(); /* display a "charging" screen */
203 if (rc
== 1) /* charger removed */
205 /* "On" pressed or USB connected: proceed */
206 show_logo(); /* again, to provide better visual feedback */
213 #ifdef HAVE_LCD_BITMAP
216 snprintf(str
, 31, "ATA error: %d", rc
);
218 lcd_puts(0, 3, "Press ON to debug");
220 while(!(button_get(true) & BUTTON_REL
));
223 panicf("ata: %d", rc
);
226 usb_start_monitoring();
228 { /* enter USB mode early, before trying to mount */
229 if (button_get_w_tmo(HZ
/10) == SYS_USB_CONNECTED
)
231 if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED
))
235 mounted
= true; /* mounting done @ end of USB mode */
237 #ifdef HAVE_USB_POWER
238 if (usb_powered()) /* avoid deadlock */
245 rc
= disk_mount_all();
249 lcd_puts(0, 0, "No partition");
250 lcd_puts(0, 1, "found.");
251 #ifdef HAVE_LCD_BITMAP
252 lcd_puts(0, 2, "Insert USB cable");
253 lcd_puts(0, 3, "and fix it.");
256 while(button_get(true) != SYS_USB_CONNECTED
) {};
262 /* On software codec platforms we have to init audio before
263 calling audio_set_buffer_margin(). */
264 #if (CONFIG_HWCODEC == MASNONE)
267 settings_calc_config_sector();
268 settings_load(SETTINGS_ALL
);
275 /* No buffer allocation (see buffer.c) may take place after the call to
276 audio_init() since the mpeg thread takes the rest of the buffer space */
277 mp3_init( global_settings
.volume
,
278 global_settings
.bass
,
279 global_settings
.treble
,
280 global_settings
.balance
,
281 global_settings
.loudness
,
283 global_settings
.channel_config
,
284 global_settings
.stereo_width
,
285 global_settings
.mdb_strength
,
286 global_settings
.mdb_harmonics
,
287 global_settings
.mdb_center
,
288 global_settings
.mdb_shape
,
289 global_settings
.mdb_enable
,
290 global_settings
.superbass
);
291 #if (CONFIG_HWCODEC == MASNONE)
292 sound_settings_apply();
296 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
297 pcm_init_recording();
300 /* runtime database has to be initialized after audio_init() */
307 static const char filename
[] = PLUGIN_DIR
"/autostart.rock";
309 fd
= open(filename
, O_RDONLY
);
310 if(fd
>= 0) /* no complaint if it doesn't exist */
313 plugin_load((char*)filename
, NULL
); /* start if it does */
316 #endif /* #ifdef AUTOROCK */
319 car_adapter_mode_init();
328 #if CONFIG_LED == LED_REAL
329 led(true); sleep(HZ
/10);
330 led(false); sleep(HZ
/10);