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"
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
);
141 gui_sync_data_wps_init();
148 mp3_init( global_settings
.volume
,
149 global_settings
.bass
,
150 global_settings
.treble
,
151 global_settings
.balance
,
152 global_settings
.loudness
,
154 global_settings
.channel_config
,
155 global_settings
.stereo_width
,
156 global_settings
.mdb_strength
,
157 global_settings
.mdb_harmonics
,
158 global_settings
.mdb_center
,
159 global_settings
.mdb_shape
,
160 global_settings
.mdb_enable
,
161 global_settings
.superbass
);
163 button_clear_queue(); /* Empty the keyboard buffer */
164 #if CONFIG_CODEC == SWCODEC
174 bool mounted
= false;
175 #if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
176 /* if nobody initialized ATA before, I consider this a cold start */
177 bool coldstart
= (PACR2
& 0x4000) != 0; /* starting from Flash */
182 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
183 set_cpu_frequency(CPUFREQ_NORMAL
);
191 #ifdef HAVE_REMOTE_LCD
202 #ifndef HAVE_MMC /* FIXME: This is also necessary for debug builds
203 * (do debug builds on the Ondio make sense?) */
212 settings_load(SETTINGS_RTC
); /* early load parts of global_settings */
229 #if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
230 if (coldstart
&& charger_inserted()
231 && !global_settings
.car_adapter_mode
232 #ifdef ATA_POWER_PLAYERSTYLE
233 && !ide_powered() /* relies on probing result from bootloader */
237 rc
= charging_screen(); /* display a "charging" screen */
238 if (rc
== 1) /* charger removed */
240 /* "On" pressed or USB connected: proceed */
241 show_logo(); /* again, to provide better visual feedback */
248 #ifdef HAVE_LCD_BITMAP
251 snprintf(str
, 31, "ATA error: %d", rc
);
253 lcd_puts(0, 3, "Press ON to debug");
255 while(!(button_get(true) & BUTTON_REL
));
258 panicf("ata: %d", rc
);
261 usb_start_monitoring();
263 { /* enter USB mode early, before trying to mount */
264 if (button_get_w_tmo(HZ
/10) == SYS_USB_CONNECTED
)
266 if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED
))
270 mounted
= true; /* mounting done @ end of USB mode */
272 #ifdef HAVE_USB_POWER
273 if (usb_powered()) /* avoid deadlock */
280 rc
= disk_mount_all();
284 lcd_puts(0, 0, "No partition");
285 lcd_puts(0, 1, "found.");
286 #ifdef HAVE_LCD_BITMAP
287 lcd_puts(0, 2, "Insert USB cable");
288 lcd_puts(0, 3, "and fix it.");
291 while(button_get(true) != SYS_USB_CONNECTED
) {};
297 settings_calc_config_sector();
298 settings_load(SETTINGS_ALL
);
300 gui_sync_data_wps_init();
308 /* No buffer allocation (see buffer.c) may take place after the call to
309 audio_init() since the mpeg thread takes the rest of the buffer space */
310 mp3_init( global_settings
.volume
,
311 global_settings
.bass
,
312 global_settings
.treble
,
313 global_settings
.balance
,
314 global_settings
.loudness
,
316 global_settings
.channel_config
,
317 global_settings
.stereo_width
,
318 global_settings
.mdb_strength
,
319 global_settings
.mdb_harmonics
,
320 global_settings
.mdb_center
,
321 global_settings
.mdb_shape
,
322 global_settings
.mdb_enable
,
323 global_settings
.superbass
);
325 #if (CONFIG_CODEC == SWCODEC)
326 sound_settings_apply();
328 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
332 /* runtime database has to be initialized after audio_init() */
339 static const char filename
[] = PLUGIN_DIR
"/autostart.rock";
341 fd
= open(filename
, O_RDONLY
);
342 if(fd
>= 0) /* no complaint if it doesn't exist */
345 plugin_load((char*)filename
, NULL
); /* start if it does */
348 #endif /* #ifdef AUTOROCK */
351 car_adapter_mode_init();
360 #if CONFIG_LED == LED_REAL
361 led(true); sleep(HZ
/10);
362 led(false); sleep(HZ
/10);