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"
52 #include "wps-display.h"
66 #if (CONFIG_CODEC == SWCODEC)
71 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
72 #include "pcm_record.h"
82 #ifdef HAVE_REMOTE_LCD
83 #include "lcd-remote.h"
86 /*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
88 const char appsversion
[]=APPSVERSION
;
99 void init_dircache(void)
104 if (global_settings
.dircache
)
106 /* Print "Scanning disk..." to the display. */
107 lcd_getstringsize("A", &font_w
, &font_h
);
108 lcd_putsxy((LCD_WIDTH
/2) - ((strlen(str(LANG_DIRCACHE_BUILDING
))*font_w
)/2),
109 LCD_HEIGHT
-font_h
*3, str(LANG_DIRCACHE_BUILDING
));
112 dircache_build(global_settings
.dircache_size
);
114 /* Clean the text when we are done. */
115 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
116 lcd_fillrect(0, LCD_HEIGHT
-font_h
*3, LCD_WIDTH
, font_h
);
117 lcd_set_drawmode(DRMODE_SOLID
);
122 # define init_dircache(...)
132 #ifdef HAVE_REMOTE_LCD
139 settings_calc_config_sector();
140 settings_load(SETTINGS_ALL
);
146 mp3_init( global_settings
.volume
,
147 global_settings
.bass
,
148 global_settings
.treble
,
149 global_settings
.balance
,
150 global_settings
.loudness
,
152 global_settings
.channel_config
,
153 global_settings
.stereo_width
,
154 global_settings
.mdb_strength
,
155 global_settings
.mdb_harmonics
,
156 global_settings
.mdb_center
,
157 global_settings
.mdb_shape
,
158 global_settings
.mdb_enable
,
159 global_settings
.superbass
);
161 button_clear_queue(); /* Empty the keyboard buffer */
162 #if CONFIG_CODEC == SWCODEC
172 bool mounted
= false;
173 #if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
174 /* if nobody initialized ATA before, I consider this a cold start */
175 bool coldstart
= (PACR2
& 0x4000) != 0; /* starting from Flash */
180 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
181 set_cpu_frequency(CPUFREQ_NORMAL
);
189 #ifdef HAVE_REMOTE_LCD
200 #ifndef HAVE_MMC /* FIXME: This is also necessary for debug builds
201 * (do debug builds on the Ondio make sense?) */
210 settings_load(SETTINGS_RTC
); /* early load parts of global_settings */
227 #if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
228 if (coldstart
&& charger_inserted()
229 && !global_settings
.car_adapter_mode
230 #ifdef ATA_POWER_PLAYERSTYLE
231 && !ide_powered() /* relies on probing result from bootloader */
235 rc
= charging_screen(); /* display a "charging" screen */
236 if (rc
== 1) /* charger removed */
238 /* "On" pressed or USB connected: proceed */
239 show_logo(); /* again, to provide better visual feedback */
246 #ifdef HAVE_LCD_BITMAP
249 snprintf(str
, 31, "ATA error: %d", rc
);
251 lcd_puts(0, 3, "Press ON to debug");
253 while(!(button_get(true) & BUTTON_REL
));
256 panicf("ata: %d", rc
);
259 usb_start_monitoring();
261 { /* enter USB mode early, before trying to mount */
262 if (button_get_w_tmo(HZ
/10) == SYS_USB_CONNECTED
)
264 if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED
))
268 mounted
= true; /* mounting done @ end of USB mode */
270 #ifdef HAVE_USB_POWER
271 if (usb_powered()) /* avoid deadlock */
278 rc
= disk_mount_all();
282 lcd_puts(0, 0, "No partition");
283 lcd_puts(0, 1, "found.");
284 #ifdef HAVE_LCD_BITMAP
285 lcd_puts(0, 2, "Insert USB cable");
286 lcd_puts(0, 3, "and fix it.");
289 while(button_get(true) != SYS_USB_CONNECTED
) {};
295 settings_calc_config_sector();
296 settings_load(SETTINGS_ALL
);
305 /* No buffer allocation (see buffer.c) may take place after the call to
306 audio_init() since the mpeg thread takes the rest of the buffer space */
307 mp3_init( global_settings
.volume
,
308 global_settings
.bass
,
309 global_settings
.treble
,
310 global_settings
.balance
,
311 global_settings
.loudness
,
313 global_settings
.channel_config
,
314 global_settings
.stereo_width
,
315 global_settings
.mdb_strength
,
316 global_settings
.mdb_harmonics
,
317 global_settings
.mdb_center
,
318 global_settings
.mdb_shape
,
319 global_settings
.mdb_enable
,
320 global_settings
.superbass
);
322 #if (CONFIG_CODEC == SWCODEC)
323 sound_settings_apply();
325 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
326 pcm_init_recording();
329 /* runtime database has to be initialized after audio_init() */
336 static const char filename
[] = PLUGIN_DIR
"/autostart.rock";
338 fd
= open(filename
, O_RDONLY
);
339 if(fd
>= 0) /* no complaint if it doesn't exist */
342 plugin_load((char*)filename
, NULL
); /* start if it does */
345 #endif /* #ifdef AUTOROCK */
348 car_adapter_mode_init();
357 #if CONFIG_LED == LED_REAL
358 led(true); sleep(HZ
/10);
359 led(false); sleep(HZ
/10);