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"
45 #include "backlight.h"
47 #include "debug_menu.h"
69 #if (CONFIG_CODEC == SWCODEC)
75 #if (defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)) && !defined(SIMULATOR)
76 #include "pcm_record.h"
77 #define SETTINGS_RESET BUTTON_REC
87 #ifdef HAVE_REMOTE_LCD
88 #include "lcd-remote.h"
91 /*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
93 const char appsversion
[]=APPSVERSION
;
104 void init_dircache(void)
110 if (global_settings
.dircache
)
112 if (global_settings
.dircache_size
== 0)
114 gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING
));
118 result
= dircache_build(global_settings
.dircache_size
);
120 gui_syncsplash(0, true, "Failed! Result: %d", result
);
130 # define init_dircache(...)
133 void init_tagcache(void)
139 while (!tagcache_is_initialized())
141 #ifdef HAVE_LCD_CHARCELLS
144 int ret
= tagcache_get_commit_step();
148 #ifdef HAVE_LCD_BITMAP
149 gui_syncsplash(0, true, "%s [%d/%d]",
150 str(LANG_TAGCACHE_INIT
), ret
, TAG_COUNT
);
152 lcd_double_height(false);
153 snprintf(buf
, sizeof(buf
), " TC [%d/%d]", ret
, TAG_COUNT
);
176 #ifdef HAVE_REMOTE_LCD
184 /* Must be done before any code uses the multi-screen APi */
185 screen_access_init();
186 gui_syncstatusbar_init(&statusbars
);
188 settings_calc_config_sector();
189 settings_load(SETTINGS_ALL
);
197 mp3_init( global_settings
.volume
,
198 global_settings
.bass
,
199 global_settings
.treble
,
200 global_settings
.balance
,
201 global_settings
.loudness
,
203 global_settings
.channel_config
,
204 global_settings
.stereo_width
,
205 global_settings
.mdb_strength
,
206 global_settings
.mdb_harmonics
,
207 global_settings
.mdb_center
,
208 global_settings
.mdb_shape
,
209 global_settings
.mdb_enable
,
210 global_settings
.superbass
);
212 #if CONFIG_CODEC == SWCODEC
216 /* audio_init must to know the size of voice buffer so init voice first */
217 #if CONFIG_CODEC == SWCODEC
222 button_clear_queue(); /* Empty the keyboard buffer */
230 bool mounted
= false;
231 #if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034)
232 /* if nobody initialized ATA before, I consider this a cold start */
233 bool coldstart
= (PACR2
& 0x4000) != 0; /* starting from Flash */
238 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
239 set_cpu_frequency(CPUFREQ_NORMAL
);
251 #ifdef HAVE_REMOTE_LCD
261 #ifndef HAVE_MMC /* FIXME: This is also necessary for debug builds
262 * (do debug builds on the Ondio make sense?) */
273 settings_load(SETTINGS_RTC
); /* early load parts of global_settings */
286 #if CONFIG_CODEC == SWCODEC
294 /* Must be done before any code uses the multi-screen APi */
295 screen_access_init();
296 gui_syncstatusbar_init(&statusbars
);
298 #if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034)
299 if (coldstart
&& charger_inserted()
300 && !global_settings
.car_adapter_mode
301 #ifdef ATA_POWER_PLAYERSTYLE
302 && !ide_powered() /* relies on probing result from bootloader */
306 rc
= charging_screen(); /* display a "charging" screen */
307 if (rc
== 1) /* charger removed */
309 /* "On" pressed or USB connected: proceed */
310 show_logo(); /* again, to provide better visual feedback */
317 #ifdef HAVE_LCD_BITMAP
320 snprintf(str
, 31, "ATA error: %d", rc
);
322 lcd_puts(0, 3, "Press ON to debug");
324 while(!(button_get(true) & BUTTON_REL
));
327 panicf("ata: %d", rc
);
330 usb_start_monitoring();
332 { /* enter USB mode early, before trying to mount */
333 if (button_get_w_tmo(HZ
/10) == SYS_USB_CONNECTED
)
335 if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED
))
339 mounted
= true; /* mounting done @ end of USB mode */
341 #ifdef HAVE_USB_POWER
342 if (usb_powered()) /* avoid deadlock */
349 rc
= disk_mount_all();
353 lcd_puts(0, 0, "No partition");
354 lcd_puts(0, 1, "found.");
355 #ifdef HAVE_LCD_BITMAP
356 lcd_puts(0, 2, "Insert USB cable");
357 lcd_puts(0, 3, "and fix it.");
360 while(button_get(true) != SYS_USB_CONNECTED
) {};
366 settings_calc_config_sector();
368 #if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD)
369 #ifdef SETTINGS_RESET
370 /* Reset settings if holding the rec button. */
371 if ((button_status() & SETTINGS_RESET
) == SETTINGS_RESET
)
373 /* Reset settings if the hold button is turned on */
377 gui_syncsplash(HZ
*2, true, str(LANG_RESET_DONE_CLEAR
));
382 settings_load(SETTINGS_ALL
);
394 /* No buffer allocation (see buffer.c) may take place after the call to
395 audio_init() since the mpeg thread takes the rest of the buffer space */
396 mp3_init( global_settings
.volume
,
397 global_settings
.bass
,
398 global_settings
.treble
,
399 global_settings
.balance
,
400 global_settings
.loudness
,
402 global_settings
.channel_config
,
403 global_settings
.stereo_width
,
404 global_settings
.mdb_strength
,
405 global_settings
.mdb_harmonics
,
406 global_settings
.mdb_center
,
407 global_settings
.mdb_shape
,
408 global_settings
.mdb_enable
,
409 global_settings
.superbass
);
411 /* audio_init must to know the size of voice buffer so init voice first */
415 #if (defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)) && !defined(SIMULATOR)
419 /* runtime database has to be initialized after audio_init() */
425 static const char filename
[] = PLUGIN_DIR
"/autostart.rock";
427 fd
= open(filename
, O_RDONLY
);
428 if(fd
>= 0) /* no complaint if it doesn't exist */
431 plugin_load((char*)filename
, NULL
); /* start if it does */
434 #endif /* #ifdef AUTOROCK */
436 #ifdef CONFIG_CHARGING
437 car_adapter_mode_init();
446 #if CONFIG_LED == LED_REAL
447 led(true); sleep(HZ
/10);
448 led(false); sleep(HZ
/10);