static void chart_configure(GtkWidget *widget, GdkEvent *event, void *nil) { CHART(widget)->points_in_view = widget->allocation.width; if (!CHART(widget)->colormap) CHART(widget)->colormap = gdk_drawable_get_colormap(widget->window); }
int main(int argc, char *argv[]) { sys_handle_argv(argc, argv); #else int main(void) INIT_ATTR MAIN_NORETURN_ATTR; int main(void) { #endif int i; CHART(">init"); init(); CHART("<init"); FOR_NB_SCREENS(i) { screens[i].clear_display(); screens[i].update(); } #ifdef HAVE_LCD_BITMAP list_init(); #endif tree_gui_init(); /* Keep the order of this 3 * Must be done before any code uses the multi-screen API */ #ifdef HAVE_USBSTACK /* All threads should be created and public queues registered by now */ usb_start_monitoring(); #endif #ifdef AUTOROCK { char filename[MAX_PATH]; const char *file = #ifdef APPLICATION ROCKBOX_DIR #else PLUGIN_APPS_DIR #endif "/autostart.rock"; if(file_exists(file)) /* no complaint if it doesn't exist */ { plugin_load(file, NULL); /* start if it does */ } } #endif /* #ifdef AUTOROCK */ global_status.last_volume_change = 0; /* no calls INIT_ATTR functions after this point anymore! * see definition of INIT_ATTR in config.h */ CHART(">root_menu"); root_menu(); }
static void init(void) { int rc; bool mounted = false; #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) /* if nobody initialized ATA before, I consider this a cold start */ bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */ #endif system_init(); kernel_init(); #ifdef HAVE_ADJUSTABLE_CPU_FREQ set_cpu_frequency(CPUFREQ_NORMAL); #ifdef CPU_COLDFIRE coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS); #endif cpu_boost(true); #endif buffer_init(); settings_reset(); i2c_init(); power_init(); enable_irq(); #ifdef CPU_ARM enable_fiq(); #endif /* current_tick should be ticking by now */ CHART("ticking"); lcd_init(); #ifdef HAVE_REMOTE_LCD lcd_remote_init(); #endif font_init(); CHART(">show_logo"); show_logo(); CHART("<show_logo"); lang_init(core_language_builtin, language_strings, LANG_LAST_INDEX_IN_ARRAY); #ifdef DEBUG debug_init(); #else #ifdef HAVE_SERIAL serial_setup(); #endif #endif #if CONFIG_RTC rtc_init(); #endif #ifdef HAVE_RTC_RAM CHART(">settings_load(RTC)"); settings_load(SETTINGS_RTC); /* early load parts of global_settings */ CHART("<settings_load(RTC)"); #endif adc_init(); usb_init(); #if CONFIG_USBOTG == USBOTG_ISP1362 isp1362_init(); #elif CONFIG_USBOTG == USBOTG_M5636 m5636_init(); #endif backlight_init(); button_init(); powermgmt_init(); #if CONFIG_TUNER radio_init(); #endif /* Keep the order of this 3 (viewportmanager handles statusbars) * Must be done before any code uses the multi-screen API */ CHART(">gui_syncstatusbar_init"); gui_syncstatusbar_init(&statusbars); CHART("<gui_syncstatusbar_init"); CHART(">sb_skin_init"); sb_skin_init(); CHART("<sb_skin_init"); CHART(">gui_sync_wps_init"); gui_sync_wps_init(); CHART("<gui_sync_wps_init"); CHART(">viewportmanager_init"); viewportmanager_init(); CHART("<viewportmanager_init"); #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) /* charger_inserted() can't be used here because power_thread() hasn't checked power_input_status() yet */ if (coldstart && (power_input_status() & POWER_INPUT_MAIN_CHARGER) && !global_settings.car_adapter_mode #ifdef ATA_POWER_PLAYERSTYLE && !ide_powered() /* relies on probing result from bootloader */ #endif ) { rc = charging_screen(); /* display a "charging" screen */ if (rc == 1) /* charger removed */ power_off(); /* "On" pressed or USB connected: proceed */ show_logo(); /* again, to provide better visual feedback */ } #endif CHART(">storage_init"); rc = storage_init(); CHART("<storage_init"); if(rc) { #ifdef HAVE_LCD_BITMAP lcd_clear_display(); lcd_putsf(0, 1, "ATA error: %d", rc); lcd_puts(0, 3, "Press ON to debug"); lcd_update(); while(!(button_get(true) & BUTTON_REL)); /*DO NOT CHANGE TO ACTION SYSTEM */ dbg_ports(); #endif panicf("ata: %d", rc); } #ifdef HAVE_EEPROM_SETTINGS CHART(">eeprom_settings_init"); eeprom_settings_init(); CHART("<eeprom_settings_init"); #endif #ifndef HAVE_USBSTACK usb_start_monitoring(); while (usb_detect() == USB_INSERTED) { #ifdef HAVE_EEPROM_SETTINGS firmware_settings.disk_clean = false; #endif /* enter USB mode early, before trying to mount */ if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED) #if (CONFIG_STORAGE & STORAGE_MMC) if (!mmc_touched() || (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED)) #endif { gui_usb_screen_run(); mounted = true; /* mounting done @ end of USB mode */ } #ifdef HAVE_USB_POWER if (usb_powered()) /* avoid deadlock */ break; #endif } #endif if (!mounted) { CHART(">disk_mount_all"); rc = disk_mount_all(); CHART("<disk_mount_all"); if (rc<=0) { lcd_clear_display(); lcd_puts(0, 0, "No partition"); lcd_puts(0, 1, "found."); #ifdef HAVE_LCD_BITMAP lcd_puts(0, 2, "Insert USB cable"); lcd_puts(0, 3, "and fix it."); #endif lcd_update(); while(button_get(true) != SYS_USB_CONNECTED) {}; gui_usb_screen_run(); system_reboot(); } } #if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || \ (CONFIG_KEYPAD == IRIVER_H10_PAD) #ifdef SETTINGS_RESET /* Reset settings if holding the reset button. (Rec on Archos, A on Gigabeat) */ if ((button_status() & SETTINGS_RESET) == SETTINGS_RESET) #else /* Reset settings if the hold button is turned on */ if (button_hold()) #endif { splash(HZ*2, str(LANG_RESET_DONE_CLEAR)); settings_reset(); } else #endif { CHART(">settings_load(ALL)"); settings_load(SETTINGS_ALL); CHART("<settings_load(ALL)"); } CHART(">init_dircache(true)"); rc = init_dircache(true); CHART("<init_dircache(true)"); if (rc < 0) { #ifdef HAVE_TAGCACHE remove(TAGCACHE_STATEFILE); #endif } CHART(">settings_apply(true)"); settings_apply(true); CHART("<settings_apply(true)"); CHART(">init_dircache(false)"); init_dircache(false); CHART("<init_dircache(false)"); #ifdef HAVE_TAGCACHE CHART(">init_tagcache"); init_tagcache(); CHART("<init_tagcache"); #endif #ifdef HAVE_EEPROM_SETTINGS if (firmware_settings.initialized) { /* In case we crash. */ firmware_settings.disk_clean = false; CHART(">eeprom_settings_store"); eeprom_settings_store(); CHART("<eeprom_settings_store"); } #endif playlist_init(); tree_mem_init(); filetype_init(); scrobbler_init(); #if CONFIG_CODEC == SWCODEC tdspeed_init(); #endif /* CONFIG_CODEC == SWCODEC */ #if CONFIG_CODEC != SWCODEC /* No buffer allocation (see buffer.c) may take place after the call to audio_init() since the mpeg thread takes the rest of the buffer space */ mp3_init( global_settings.volume, global_settings.bass, global_settings.treble, global_settings.balance, global_settings.loudness, global_settings.avc, global_settings.channel_config, global_settings.stereo_width, global_settings.mdb_strength, global_settings.mdb_harmonics, global_settings.mdb_center, global_settings.mdb_shape, global_settings.mdb_enable, global_settings.superbass); /* audio_init must to know the size of voice buffer so init voice first */ talk_init(); #endif /* CONFIG_CODEC != SWCODEC */ CHART(">audio_init"); audio_init(); CHART("<audio_init"); #if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR) pcm_rec_init(); #endif /* runtime database has to be initialized after audio_init() */ cpu_boost(false); #if CONFIG_CHARGING car_adapter_mode_init(); #endif #ifdef IPOD_ACCESSORY_PROTOCOL iap_setup(global_settings.serial_bitrate); #endif #ifdef HAVE_ACCESSORY_SUPPLY accessory_supply_set(global_settings.accessory_supply); #endif #ifdef HAVE_LINEOUT_POWEROFF lineout_set(global_settings.lineout_active); #endif #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN CHART("<check_bootfile(false)"); check_bootfile(false); /* remember write time and filesize */ CHART(">check_bootfile(false)"); #endif CHART("<settings_apply_skins"); settings_apply_skins(); CHART(">settings_apply_skins"); }
void settings_apply(bool read_disk) { #ifdef HAVE_LCD_BITMAP int rc; #endif CHART(">set_codepage"); set_codepage(global_settings.default_codepage); CHART("<set_codepage"); sound_settings_apply(); #ifdef HAVE_DISK_STORAGE audio_set_buffer_margin(global_settings.buffer_margin); #endif #ifdef HAVE_LCD_CONTRAST lcd_set_contrast(global_settings.contrast); #endif lcd_scroll_speed(global_settings.scroll_speed); #ifdef HAVE_REMOTE_LCD lcd_remote_set_contrast(global_settings.remote_contrast); lcd_remote_set_invert_display(global_settings.remote_invert); #ifdef HAVE_LCD_FLIP lcd_remote_set_flip(global_settings.remote_flip_display); #endif lcd_remote_scroll_speed(global_settings.remote_scroll_speed); lcd_remote_scroll_step(global_settings.remote_scroll_step); lcd_remote_scroll_delay(global_settings.remote_scroll_delay); lcd_remote_bidir_scroll(global_settings.remote_bidir_limit); #ifdef HAVE_REMOTE_LCD_TICKING lcd_remote_emireduce(global_settings.remote_reduce_ticking); #endif remote_backlight_set_timeout(global_settings.remote_backlight_timeout); #if CONFIG_CHARGING remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged); #endif #ifdef HAS_REMOTE_BUTTON_HOLD remote_backlight_set_on_button_hold(global_settings.remote_backlight_on_button_hold); #endif #endif /* HAVE_REMOTE_LCD */ #ifdef HAVE_BACKLIGHT_BRIGHTNESS backlight_set_brightness(global_settings.brightness); #endif #ifdef HAVE_BACKLIGHT backlight_set_timeout(global_settings.backlight_timeout); #if CONFIG_CHARGING backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged); #endif #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \ || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING) backlight_set_fade_in(global_settings.backlight_fade_in); backlight_set_fade_out(global_settings.backlight_fade_out); #endif #endif #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS buttonlight_set_brightness(global_settings.buttonlight_brightness); #endif #ifdef HAVE_BUTTON_LIGHT buttonlight_set_timeout(global_settings.buttonlight_timeout); #endif #ifdef HAVE_DISK_STORAGE storage_spindown(global_settings.disk_spindown); #endif #if (CONFIG_CODEC == MAS3507D) && (CONFIG_PLATFORM & PLATFORM_NATIVE) dac_line_in(global_settings.line_in); #endif set_poweroff_timeout(global_settings.poweroff); if (global_settings.sleeptimer_on_startup) set_sleeptimer_duration(global_settings.sleeptimer_duration); set_keypress_restarts_sleep_timer( global_settings.keypress_restarts_sleeptimer); #if defined(BATTERY_CAPACITY_INC) && BATTERY_CAPACITY_INC > 0 /* only call if it's really exchangable */ set_battery_capacity(global_settings.battery_capacity); #endif #if BATTERY_TYPES_COUNT > 1 set_battery_type(global_settings.battery_type); #endif #ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_INVERT lcd_set_invert_display(global_settings.invert); #endif #ifdef HAVE_LCD_FLIP lcd_set_flip(global_settings.flip_display); button_set_flip(global_settings.flip_display); #endif lcd_update(); /* refresh after flipping the screen */ settings_apply_pm_range(); peak_meter_init_times( global_settings.peak_meter_release, global_settings.peak_meter_hold, global_settings.peak_meter_clip_hold); #endif #ifdef HAVE_SPEAKER audiohw_enable_speaker(global_settings.speaker_enabled); #endif if (read_disk) { char buf[MAX_PATH]; #ifdef HAVE_LCD_BITMAP /* fonts need to be loaded before the WPS */ if (global_settings.font_file[0] && global_settings.font_file[0] != '-') { int font_ui = screens[SCREEN_MAIN].getuifont(); const char* loaded_font = font_filename(font_ui); snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.font_file); if (!loaded_font || strcmp(loaded_font, buf)) { CHART2(">font_load ", global_settings.font_file); if (font_ui >= 0) font_unload(font_ui); rc = font_load_ex(buf, 0, global_settings.glyphs_to_cache); CHART2("<font_load ", global_settings.font_file); screens[SCREEN_MAIN].setuifont(rc); screens[SCREEN_MAIN].setfont(rc); } } #ifdef HAVE_REMOTE_LCD if ( global_settings.remote_font_file[0] && global_settings.remote_font_file[0] != '-') { int font_ui = screens[SCREEN_REMOTE].getuifont(); const char* loaded_font = font_filename(font_ui); snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.remote_font_file); if (!loaded_font || strcmp(loaded_font, buf)) { CHART2(">font_load_remoteui ", global_settings.remote_font_file); if (font_ui >= 0) font_unload(font_ui); rc = font_load(buf); CHART2("<font_load_remoteui ", global_settings.remote_font_file); screens[SCREEN_REMOTE].setuifont(rc); screens[SCREEN_REMOTE].setfont(rc); } } #endif if ( global_settings.kbd_file[0] && global_settings.kbd_file[0] != '-') { snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", global_settings.kbd_file); CHART(">load_kbd"); load_kbd(buf); CHART("<load_kbd"); } else load_kbd(NULL); #endif /* HAVE_LCD_BITMAP */ if ( global_settings.lang_file[0]) { snprintf(buf, sizeof buf, LANG_DIR "/%s.lng", global_settings.lang_file); CHART(">lang_core_load"); lang_core_load(buf); CHART("<lang_core_load"); } CHART(">talk_init"); talk_init(); /* use voice of same language */ CHART("<talk_init"); /* load the icon set */ CHART(">icons_init"); icons_init(); CHART("<icons_init"); #ifdef HAVE_LCD_COLOR if (global_settings.colors_file[0] && global_settings.colors_file[0] != '-') { CHART(">read_color_theme_file"); read_color_theme_file(); CHART("<read_color_theme_file"); } #endif } #ifdef HAVE_LCD_COLOR screens[SCREEN_MAIN].set_foreground(global_settings.fg_color); screens[SCREEN_MAIN].set_background(global_settings.bg_color); #endif #ifdef HAVE_LCD_BITMAP lcd_scroll_step(global_settings.scroll_step); gui_list_screen_scroll_step(global_settings.screen_scroll_step); gui_list_screen_scroll_out_of_view(global_settings.offset_out_of_view); #endif lcd_bidir_scroll(global_settings.bidir_limit); lcd_scroll_delay(global_settings.scroll_delay); #ifdef HAVE_PLAY_FREQ settings_apply_play_freq(global_settings.play_frequency, false); #endif #if CONFIG_CODEC == SWCODEC #ifdef HAVE_CROSSFADE audio_set_crossfade(global_settings.crossfade); #endif replaygain_update(); dsp_set_crossfeed_type(global_settings.crossfeed); dsp_set_crossfeed_direct_gain(global_settings.crossfeed_direct_gain); dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, global_settings.crossfeed_hf_attenuation, global_settings.crossfeed_hf_cutoff); /* Configure software equalizer, hardware eq is handled in audio_init() */ dsp_eq_enable(global_settings.eq_enabled); dsp_set_eq_precut(global_settings.eq_precut); for(int i = 0; i < EQ_NUM_BANDS; i++) { dsp_set_eq_coefs(i, &global_settings.eq_band_settings[i]); } dsp_dither_enable(global_settings.dithering_enabled); #ifdef HAVE_PITCHCONTROL dsp_timestretch_enable(global_settings.timestretch_enabled); #endif dsp_set_compressor(&global_settings.compressor_settings); #endif #ifdef HAVE_SPDIF_POWER spdif_power_enable(global_settings.spdif_enable); #endif #ifdef HAVE_BACKLIGHT set_backlight_filter_keypress(global_settings.bl_filter_first_keypress); #ifdef HAVE_REMOTE_LCD set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress); #endif #ifdef HAS_BUTTON_HOLD backlight_set_on_button_hold(global_settings.backlight_on_button_hold); #endif #ifdef HAVE_LCD_SLEEP_SETTING lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off); #endif #endif /* HAVE_BACKLIGHT */ #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING touchpad_set_sensitivity(global_settings.touchpad_sensitivity); #endif #ifdef HAVE_TOUCHPAD_DEADZONE touchpad_set_deadzone(global_settings.touchpad_deadzone); #endif #ifdef HAVE_USB_CHARGING_ENABLE usb_charging_enable(global_settings.usb_charging); #endif #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode(global_settings.touch_mode); memcpy(&calibration_parameters, &global_settings.ts_calibration_data, sizeof(struct touchscreen_parameter)); #endif /* This should stay last */ #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC enc_global_settings_apply(); #endif #ifdef HAVE_LCD_BITMAP /* already called with THEME_STATUSBAR in settings_apply_skins() */ CHART(">viewportmanager_theme_changed"); viewportmanager_theme_changed(THEME_UI_VIEWPORT|THEME_LANGUAGE|THEME_BUTTONBAR); CHART("<viewportmanager_theme_changed"); #endif }