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 #if CONFIG_USBOTG == USBOTG_ISP1362
95 #if CONFIG_USBOTG == USBOTG_M5636
99 /*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
101 const char appsversion
[]=APPSVERSION
;
112 void init_dircache(void)
118 if (global_settings
.dircache
)
120 if (global_settings
.dircache_size
== 0)
122 gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING
));
126 result
= dircache_build(global_settings
.dircache_size
);
128 gui_syncsplash(0, true, "Failed! Result: %d", result
);
138 # define init_dircache(...)
141 void init_tagcache(void)
147 while (!tagcache_is_initialized())
149 #ifdef HAVE_LCD_CHARCELLS
152 int ret
= tagcache_get_commit_step();
156 #ifdef HAVE_LCD_BITMAP
157 gui_syncsplash(0, true, "%s [%d/%d]",
158 str(LANG_TAGCACHE_INIT
), ret
, TAG_COUNT
);
160 lcd_double_height(false);
161 snprintf(buf
, sizeof(buf
), " TC [%d/%d]", ret
, TAG_COUNT
);
184 #ifdef HAVE_REMOTE_LCD
192 /* Must be done before any code uses the multi-screen APi */
193 screen_access_init();
194 gui_syncstatusbar_init(&statusbars
);
196 settings_calc_config_sector();
197 settings_load(SETTINGS_ALL
);
205 mp3_init( global_settings
.volume
,
206 global_settings
.bass
,
207 global_settings
.treble
,
208 global_settings
.balance
,
209 global_settings
.loudness
,
211 global_settings
.channel_config
,
212 global_settings
.stereo_width
,
213 global_settings
.mdb_strength
,
214 global_settings
.mdb_harmonics
,
215 global_settings
.mdb_center
,
216 global_settings
.mdb_shape
,
217 global_settings
.mdb_enable
,
218 global_settings
.superbass
);
220 #if CONFIG_CODEC == SWCODEC
224 /* audio_init must to know the size of voice buffer so init voice first */
225 #if CONFIG_CODEC == SWCODEC
230 button_clear_queue(); /* Empty the keyboard buffer */
238 bool mounted
= false;
239 #if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034)
240 /* if nobody initialized ATA before, I consider this a cold start */
241 bool coldstart
= (PACR2
& 0x4000) != 0; /* starting from Flash */
246 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
247 set_cpu_frequency(CPUFREQ_NORMAL
);
259 #ifdef HAVE_REMOTE_LCD
269 #ifndef HAVE_MMC /* FIXME: This is also necessary for debug builds
270 * (do debug builds on the Ondio make sense?) */
281 settings_load(SETTINGS_RTC
); /* early load parts of global_settings */
287 #if CONFIG_USBOTG == USBOTG_ISP1362
289 #elif CONFIG_USBOTG == USBOTG_M5636
299 #if CONFIG_CODEC == SWCODEC
307 /* Must be done before any code uses the multi-screen APi */
308 screen_access_init();
309 gui_syncstatusbar_init(&statusbars
);
311 #if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034)
312 if (coldstart
&& charger_inserted()
313 && !global_settings
.car_adapter_mode
314 #ifdef ATA_POWER_PLAYERSTYLE
315 && !ide_powered() /* relies on probing result from bootloader */
319 rc
= charging_screen(); /* display a "charging" screen */
320 if (rc
== 1) /* charger removed */
322 /* "On" pressed or USB connected: proceed */
323 show_logo(); /* again, to provide better visual feedback */
330 #ifdef HAVE_LCD_BITMAP
333 snprintf(str
, 31, "ATA error: %d", rc
);
335 lcd_puts(0, 3, "Press ON to debug");
337 while(!(button_get(true) & BUTTON_REL
));
340 panicf("ata: %d", rc
);
343 usb_start_monitoring();
345 { /* enter USB mode early, before trying to mount */
346 if (button_get_w_tmo(HZ
/10) == SYS_USB_CONNECTED
)
348 if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED
))
352 mounted
= true; /* mounting done @ end of USB mode */
354 #ifdef HAVE_USB_POWER
355 if (usb_powered()) /* avoid deadlock */
362 rc
= disk_mount_all();
366 lcd_puts(0, 0, "No partition");
367 lcd_puts(0, 1, "found.");
368 #ifdef HAVE_LCD_BITMAP
369 lcd_puts(0, 2, "Insert USB cable");
370 lcd_puts(0, 3, "and fix it.");
373 while(button_get(true) != SYS_USB_CONNECTED
) {};
379 settings_calc_config_sector();
381 #if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD)
382 #ifdef SETTINGS_RESET
383 /* Reset settings if holding the rec button. */
384 if ((button_status() & SETTINGS_RESET
) == SETTINGS_RESET
)
386 /* Reset settings if the hold button is turned on */
390 gui_syncsplash(HZ
*2, true, str(LANG_RESET_DONE_CLEAR
));
395 settings_load(SETTINGS_ALL
);
407 /* No buffer allocation (see buffer.c) may take place after the call to
408 audio_init() since the mpeg thread takes the rest of the buffer space */
409 mp3_init( global_settings
.volume
,
410 global_settings
.bass
,
411 global_settings
.treble
,
412 global_settings
.balance
,
413 global_settings
.loudness
,
415 global_settings
.channel_config
,
416 global_settings
.stereo_width
,
417 global_settings
.mdb_strength
,
418 global_settings
.mdb_harmonics
,
419 global_settings
.mdb_center
,
420 global_settings
.mdb_shape
,
421 global_settings
.mdb_enable
,
422 global_settings
.superbass
);
424 /* audio_init must to know the size of voice buffer so init voice first */
428 #if (defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)) && !defined(SIMULATOR)
432 /* runtime database has to be initialized after audio_init() */
438 static const char filename
[] = PLUGIN_DIR
"/autostart.rock";
440 fd
= open(filename
, O_RDONLY
);
441 if(fd
>= 0) /* no complaint if it doesn't exist */
444 plugin_load((char*)filename
, NULL
); /* start if it does */
447 #endif /* #ifdef AUTOROCK */
449 #ifdef CONFIG_CHARGING
450 car_adapter_mode_init();
459 #if CONFIG_LED == LED_REAL
460 led(true); sleep(HZ
/10);
461 led(false); sleep(HZ
/10);