int video_init(void) { osd_create_params params; artwork_callbacks *artcallbacks; int bmwidth = Machine->drv->screen_width; int bmheight = Machine->drv->screen_height; movie_file = NULL; movie_frame = 0; add_pause_callback(video_pause); add_exit_callback(video_exit); /* first allocate the necessary palette structures */ if (palette_start()) return 1; #ifndef NEW_RENDER /* if we're a vector game, override the screen width and height */ if (Machine->drv->video_attributes & VIDEO_TYPE_VECTOR) scale_vectorgames(options.vector_width, options.vector_height, &bmwidth, &bmheight); /* compute the visible area for raster games */ if (!(Machine->drv->video_attributes & VIDEO_TYPE_VECTOR)) { params.width = Machine->drv->default_visible_area.max_x - Machine->drv->default_visible_area.min_x + 1; params.height = Machine->drv->default_visible_area.max_y - Machine->drv->default_visible_area.min_y + 1; } else { params.width = bmwidth; params.height = bmheight; } /* fill in the rest of the display parameters */ compute_aspect_ratio(Machine->drv, ¶ms.aspect_x, ¶ms.aspect_y); params.depth = Machine->color_depth; params.colors = palette_get_total_colors_with_ui(); params.fps = Machine->drv->frames_per_second; params.video_attributes = Machine->drv->video_attributes; #ifdef MESS artcallbacks = &mess_artwork_callbacks; #else artcallbacks = &mame_artwork_callbacks; #endif /* initialize the display through the artwork (and eventually the OSD) layer */ if (artwork_create_display(¶ms, direct_rgb_components, artcallbacks)) return 1; /* the create display process may update the vector width/height, so recompute */ if (Machine->drv->video_attributes & VIDEO_TYPE_VECTOR) scale_vectorgames(options.vector_width, options.vector_height, &bmwidth, &bmheight); /* now allocate the screen bitmap */ scrbitmap[0] = auto_bitmap_alloc_depth(bmwidth, bmheight, Machine->color_depth); if (!scrbitmap[0]) return 1; #endif /* set the default refresh rate */ set_refresh_rate(Machine->drv->frames_per_second); /* set the default visible area */ set_visible_area(0,1,0,1); // make sure everything is recalculated on multiple runs set_visible_area( Machine->drv->default_visible_area.min_x, Machine->drv->default_visible_area.max_x, Machine->drv->default_visible_area.min_y, Machine->drv->default_visible_area.max_y); /* create spriteram buffers if necessary */ if (Machine->drv->video_attributes & VIDEO_BUFFERS_SPRITERAM) if (init_buffered_spriteram()) return 1; #ifndef NEW_RENDER #if defined(MAME_DEBUG) && !defined(NEW_DEBUGGER) /* if the debugger is enabled, initialize its bitmap and font */ if (Machine->debug_mode) { int depth = options.debug_depth ? options.debug_depth : Machine->color_depth; /* first allocate the debugger bitmap */ Machine->debug_bitmap = auto_bitmap_alloc_depth(options.debug_width, options.debug_height, depth); if (!Machine->debug_bitmap) return 1; /* then create the debugger font */ Machine->debugger_font = build_debugger_font(); if (Machine->debugger_font == NULL) return 1; } #endif #endif /* convert the gfx ROMs into character sets. This is done BEFORE calling the driver's */ /* palette_init() routine because it might need to check the Machine->gfx[] data */ if (Machine->drv->gfxdecodeinfo) if (allocate_graphics(Machine->drv->gfxdecodeinfo)) return 1; /* initialize the palette - must be done after osd_create_display() */ if (palette_init()) return 1; /* force the first update to be full */ set_vh_global_attribute(NULL, 0); /* actually decode the graphics */ if (Machine->drv->gfxdecodeinfo) decode_graphics(Machine->drv->gfxdecodeinfo); /* reset performance data */ last_fps_time = osd_cycles(); rendered_frames_since_last_fps = frames_since_last_fps = 0; performance.game_speed_percent = 100; performance.frames_per_second = Machine->refresh_rate; performance.vector_updates_last_second = 0; /* reset video statics and get out of here */ pdrawgfx_shadow_lowpri = 0; leds_status = 0; /* initialize tilemaps */ if (tilemap_init() != 0) fatalerror("tilemap_init failed"); return 0; }
static void tmu_monitor(struct work_struct *work) { struct delayed_work *delayed_work = to_delayed_work(work); struct tmu_info *info = container_of(delayed_work, struct tmu_info, polling); struct tmu_data *data = info->dev->platform_data; int cur_temp; cur_temp = get_cur_temp(info); #ifdef CONFIG_TMU_DEBUG cancel_delayed_work(&info->monitor); pr_info("Current: %dc, FLAG=%d\n", cur_temp, info->tmu_state); #endif mutex_lock(&tmu_lock); switch (info->tmu_state) { #if defined(CONFIG_TC_VOLTAGE) case TMU_STATUS_TC: if (cur_temp >= data->ts.stop_tc) { if (exynos_tc_volt(info, 0) < 0) pr_err("%s\n", __func__); info->tmu_state = TMU_STATUS_NORMAL; already_limit = 0; pr_info("TC limit is released!!\n"); } else if (cur_temp <= data->ts.start_tc && !already_limit) { if (exynos_tc_volt(info, 1) < 0) pr_err("%s\n", __func__); already_limit = 1; } break; #endif case TMU_STATUS_NORMAL: #ifdef CONFIG_TMU_DEBUG queue_delayed_work_on(0, tmu_monitor_wq, &info->monitor, info->sampling_rate); #endif __raw_writel((CLEAR_RISE_INT|CLEAR_FALL_INT), info->tmu_base + INTCLEAR); enable_irq(info->irq); mutex_unlock(&tmu_lock); return; case TMU_STATUS_THROTTLED: if (cur_temp >= data->ts.start_warning) { info->tmu_state = TMU_STATUS_WARNING; exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); already_limit = 0; } else if (cur_temp > data->ts.stop_throttle && cur_temp < data->ts.start_warning && !already_limit) { exynos_cpufreq_upper_limit(DVFS_LOCK_ID_TMU, info->throttle_freq); already_limit = 1; } else if (cur_temp <= data->ts.stop_throttle) { info->tmu_state = TMU_STATUS_NORMAL; exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); pr_info("Freq limit is released!!\n"); already_limit = 0; } break; case TMU_STATUS_WARNING: if (cur_temp >= data->ts.start_tripping) { info->tmu_state = TMU_STATUS_TRIPPED; already_limit = 0; } else if (cur_temp > data->ts.stop_warning && \ cur_temp < data->ts.start_tripping && !already_limit) { exynos_cpufreq_upper_limit(DVFS_LOCK_ID_TMU, info->warning_freq); already_limit = 1; } else if (cur_temp <= data->ts.stop_warning) { info->tmu_state = TMU_STATUS_THROTTLED; exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); already_limit = 0; } break; case TMU_STATUS_TRIPPED: mutex_unlock(&tmu_lock); tmu_tripped_cb(); return; default: break; } /* memory throttling */ if (cur_temp >= data->ts.start_mem_throttle && !(auto_refresh_changed)) { pr_info("set auto_refresh 1.95us\n"); set_refresh_rate(info->auto_refresh_tq0); auto_refresh_changed = 1; } else if (cur_temp <= (data->ts.stop_mem_throttle) && (auto_refresh_changed)) { pr_info("set auto_refresh 3.9us\n"); set_refresh_rate(info->auto_refresh_normal); auto_refresh_changed = 0; } queue_delayed_work_on(0, tmu_monitor_wq, &info->polling, info->sampling_rate); mutex_unlock(&tmu_lock); return; }
static void exynos4_handler_tmu_state(struct work_struct *work) { struct delayed_work *delayed_work = to_delayed_work(work); struct s5p_tmu_info *info = container_of(delayed_work, struct s5p_tmu_info, polling); struct s5p_platform_tmu *data = info->dev->platform_data; unsigned int cur_temp; static int auto_refresh_changed; static int check_handle; int trend = 0; mutex_lock(&tmu_lock); cur_temp = get_curr_temp(info); trend = cur_temp - info->last_temperature; pr_debug("curr_temp = %u, temp_diff = %d\n", cur_temp, trend); switch (info->tmu_state) { #if defined(CONFIG_TC_VOLTAGE) case TMU_STATUS_TC: /* lock has priority than unlock */ if (cur_temp <= data->ts.start_tc) { if (exynos_tc_volt(info, 1) < 0) pr_err("TMU: lock error!\n"); } else if (cur_temp >= data->ts.stop_tc) { if (exynos_tc_volt(info, 0) < 0) { pr_err("TMU: unlock error!\n"); } else { info->tmu_state = TMU_STATUS_NORMAL; pr_info("change state: tc -> normal.\n"); } } /* free if upper limit is locked */ if (check_handle) { exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); check_handle = 0; } break; #endif case TMU_STATUS_NORMAL: /* 1. change state: 1st-throttling */ if (cur_temp >= data->ts.start_1st_throttle) { info->tmu_state = TMU_STATUS_THROTTLED; pr_info("change state: normal->throttle.\n"); #if defined(CONFIG_TC_VOLTAGE) /* check whether temp compesation need or not */ } else if (cur_temp <= data->ts.start_tc) { if (exynos_tc_volt(info, 1) < 0) { pr_err("TMU: lock error!\n"); } else { info->tmu_state = TMU_STATUS_TC; pr_info("change state: normal->tc.\n"); } #endif /* 2. polling end and uevent */ } else if ((cur_temp <= data->ts.stop_1st_throttle) && (cur_temp <= data->ts.stop_mem_throttle)) { if (check_handle & THROTTLE_FLAG) { exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); check_handle &= ~(THROTTLE_FLAG); } pr_debug("check_handle = %d\n", check_handle); notify_change_of_tmu_state(info); //pr_info("normal: free cpufreq_limit & interrupt enable.\n"); /* clear to prevent from interfupt by peindig bit */ __raw_writel(INTCLEARALL, info->tmu_base + EXYNOS4_TMU_INTCLEAR); exynos_interrupt_enable(info, 1); enable_irq(info->irq); mutex_unlock(&tmu_lock); return; } break; case TMU_STATUS_THROTTLED: /* 1. change state: 2nd-throttling or warning */ if (cur_temp >= data->ts.start_2nd_throttle) { info->tmu_state = TMU_STATUS_WARNING; pr_info("change state: 1st throttle->2nd throttle.\n"); #if defined(CONFIG_TC_VOLTAGE) /* check whether temp compesation need or not */ } else if (cur_temp <= data->ts.start_tc) { if (exynos_tc_volt(info, 1) < 0) pr_err("TMU: lock error!\n"); else info->tmu_state = TMU_STATUS_TC; #endif /* 2. cpufreq limitation and uevent */ } else if ((cur_temp >= data->ts.start_1st_throttle) && !(check_handle & THROTTLE_FLAG)) { if (check_handle & WARNING_FLAG) { exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); check_handle &= ~(WARNING_FLAG); } exynos_cpufreq_upper_limit(DVFS_LOCK_ID_TMU, info->cpufreq_level_1st_throttle); check_handle |= THROTTLE_FLAG; pr_debug("check_handle = %d\n", check_handle); notify_change_of_tmu_state(info); pr_info("throttling: set cpufreq upper limit.\n"); /* 3. change state: normal */ } else if ((cur_temp <= data->ts.stop_1st_throttle) && (trend < 0)) { info->tmu_state = TMU_STATUS_NORMAL; pr_info("change state: 1st throttle->normal.\n"); } break; case TMU_STATUS_WARNING: /* 1. change state: tripping */ if (cur_temp >= data->ts.start_tripping) { info->tmu_state = TMU_STATUS_TRIPPED; pr_info("change state: 2nd throttle->trip\n"); #if defined(CONFIG_TC_VOLTAGE) /* check whether temp compesation need or not */ } else if (cur_temp <= data->ts.start_tc) { if (exynos_tc_volt(info, 1) < 0) pr_err("TMU: lock error!\n"); else info->tmu_state = TMU_STATUS_TC; #endif /* 2. cpufreq limitation and uevent */ } else if ((cur_temp >= data->ts.start_2nd_throttle) && !(check_handle & WARNING_FLAG)) { if (check_handle & THROTTLE_FLAG) { exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); check_handle &= ~(THROTTLE_FLAG); } exynos_cpufreq_upper_limit(DVFS_LOCK_ID_TMU, info->cpufreq_level_2nd_throttle); check_handle |= WARNING_FLAG; pr_debug("check_handle = %d\n", check_handle); notify_change_of_tmu_state(info); pr_info("2nd throttle: cpufreq is limited.\n"); /* 3. change state: 1st-throttling */ } else if ((cur_temp <= data->ts.stop_2nd_throttle) && (trend < 0)) { info->tmu_state = TMU_STATUS_THROTTLED; pr_info("change state: 2nd throttle->1st throttle, " "and release cpufreq upper limit.\n"); } break; case TMU_STATUS_TRIPPED: /* 1. call uevent to shut-down */ if ((cur_temp >= data->ts.start_tripping) && (trend > 0) && !(check_handle & TRIPPING_FLAG)) { notify_change_of_tmu_state(info); pr_info("tripping: on waiting shutdown.\n"); check_handle |= TRIPPING_FLAG; pr_debug("check_handle = %d\n", check_handle); #if defined(CONFIG_TC_VOLTAGE) /* check whether temp compesation need or not */ } else if (cur_temp <= data->ts.start_tc) { if (exynos_tc_volt(info, 1) < 0) pr_err("TMU: lock error!\n"); else info->tmu_state = TMU_STATUS_TC; #endif /* 2. change state: 2nd-throttling or warning */ } else if ((cur_temp <= data->ts.stop_2nd_throttle) && (trend < 0)) { info->tmu_state = TMU_STATUS_WARNING; pr_info("change state: trip->2nd throttle, " "Check! occured only test mode.\n"); } /* 3. chip protection: kernel panic as SW workaround */ if ((cur_temp >= data->ts.start_emergency) && (trend > 0)) { panic("Emergency!!!! tripping is not treated!\n"); /* clear to prevent from interfupt by peindig bit */ __raw_writel(INTCLEARALL, info->tmu_state + EXYNOS4_TMU_INTCLEAR); enable_irq(info->irq); mutex_unlock(&tmu_lock); return; } break; case TMU_STATUS_INIT: /* sned tmu initial status to platform */ disable_irq(info->irq); if (cur_temp >= data->ts.start_tripping) info->tmu_state = TMU_STATUS_TRIPPED; #if defined(CONFIG_TC_VOLTAGE) /* check whether temp compesation need or not */ else if (cur_temp <= data->ts.start_tc) { if (exynos_tc_volt(info, 1) < 0) pr_err("TMU: lock error!\n"); else info->tmu_state = TMU_STATUS_TC; } #endif else if (cur_temp >= data->ts.start_2nd_throttle) info->tmu_state = TMU_STATUS_WARNING; else if (cur_temp >= data->ts.start_1st_throttle) info->tmu_state = TMU_STATUS_THROTTLED; else if (cur_temp <= data->ts.stop_1st_throttle) info->tmu_state = TMU_STATUS_NORMAL; notify_change_of_tmu_state(info); pr_info("%s: inform to init state to platform.\n", __func__); break; default: pr_warn("Bug: checked tmu_state.\n"); if (cur_temp >= data->ts.start_tripping) info->tmu_state = TMU_STATUS_TRIPPED; #if defined(CONFIG_TC_VOLTAGE) /* check whether temp compesation need or not */ else if (cur_temp <= data->ts.start_tc) { if (exynos_tc_volt(info, 1) < 0) pr_err("TMU: lock error!\n"); else info->tmu_state = TMU_STATUS_TC; } #endif else info->tmu_state = TMU_STATUS_WARNING; break; } /* end */ /* memory throttling */ if (cur_temp >= data->ts.start_mem_throttle) { if (!(auto_refresh_changed) && (trend > 0)) { pr_info("set auto_refresh 1.95us\n"); set_refresh_rate(info->auto_refresh_tq0); auto_refresh_changed = 1; } } else if (cur_temp <= (data->ts.stop_mem_throttle)) { if ((auto_refresh_changed) && (trend < 0)) { pr_info("set auto_refresh 3.9us\n"); set_refresh_rate(info->auto_refresh_normal); auto_refresh_changed = 0; } } info->last_temperature = cur_temp; /* reschedule the next work */ queue_delayed_work_on(0, tmu_monitor_wq, &info->polling, info->sampling_rate); mutex_unlock(&tmu_lock); return; }