/* * Resume */ int s5p_tv_late_resume(struct platform_device *dev) { BASEPRINTK("(hpd_status = %d)++\n", s5ptv_status.hpd_status); mutex_lock(mutex_for_fo); s5ptv_status.suspend_status = false; if(!(s5ptv_status.hpd_status)) { mutex_unlock(mutex_for_fo); return 0; } else { #if 0 #ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_MAX_FREQ_1GHZ // 2010.3.9. s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_4, 3); #else s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_4, 2); #endif #endif #endif #ifdef CONFIG_PM_PWR_GATING /* clk & power on */ s5p_tv_clk_gate( true ); if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB) tv_phy_power( true ); #endif /* tv on */ if ( s5ptv_status.tvout_output_enable ) { _s5p_tv_if_start(); } /* video layer start */ if ( s5ptv_status.vp_layer_enable ) _s5p_vlayer_start(); /* grp0 layer start */ if ( s5ptv_status.grp_layer_enable[0] ) _s5p_grp_start(VM_GPR0_LAYER); /* grp1 layer start */ if ( s5ptv_status.grp_layer_enable[1] ) _s5p_grp_start(VM_GPR1_LAYER); #ifdef CONFIG_TV_FB if ( s5ptv_status.tvout_output_enable ) { s5ptvfb_display_on(&s5ptv_status); s5ptvfb_set_par(s5ptv_status.fb); } #endif } mutex_unlock(mutex_for_fo); BASEPRINTK("()--\n"); return 0; }
static ssize_t dvfslock_ctrl(const char *buf, size_t count) { unsigned int ret = -EINVAL; int dlevel; int dtime_msec; //mutex_lock(&dvfslock_ctrl_mutex); ret = sscanf(buf, "%u", &gdDvfsctrl); if (ret != 1) return -EINVAL; if (!g_dbs_timer_started) return -EINVAL; if (gdDvfsctrl == 0) { if (dvfsctrl_locked) { s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_6); dvfsctrl_locked = 0; return -EINVAL; } else { return -EINVAL; } } if (dvfsctrl_locked) return 0; dlevel = gdDvfsctrl & 0xffff0000; dtime_msec = gdDvfsctrl & 0x0000ffff; if (dtime_msec <16) dtime_msec=16; if (dtime_msec == 0) return -EINVAL; if(dlevel) dlevel = LEV_800MHZ; else dlevel = LEV_1000MHZ; printk("+++++DBG dvfs lock level=%d, time=%d, scanVal=%08x\n",dlevel,dtime_msec, gdDvfsctrl); s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_6, dlevel); dvfsctrl_locked=1; schedule_delayed_work(&dvfslock_crtl_unlock_work, msecs_to_jiffies(dtime_msec)); //mutex_unlock(&dvfslock_ctrl_mutex); return -EINVAL; }
/** * enter_state - Do common work of entering low-power state. * @state: pm_state structure for state we're entering. * * Make sure we're the only ones trying to enter a sleep state. Fail * if someone has beat us to it, since we don't want anything weird to * happen when we wake up. * Then, do the setup for suspend, enter the state, and cleaup (after * we've woken up). */ static int enter_state(suspend_state_t state) { int error; extern unsigned long set1_gpio; extern unsigned long set2_gpio; if (!valid_state(state)) return -ENODEV; if (!mutex_trylock(&pm_mutex)) return -EBUSY; #ifdef CONFIG_CPU_FREQ #ifdef SLEEP_CPUFREQ_CONSERVATIVE // change cpufreq governor to performance // if conservative governor #ifdef SLEEP_CPUFREQ_MANUAL_SET if(is_userspace_gov()) { g_cpuspeed = s5pc110_getspeed(0); printk("userspace cpu speed %d \n",g_cpuspeed); userSpaceGovernor=true; } else if(is_conservative_gov()) { s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_5, 0); gbGovernorTransition=true; } #else//SLEEP_CPUFREQ_MANUAL_SET if(is_conservative_gov()) { s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_5, 0); gbGovernorTransition = true; gpio_set_value(set2_gpio, 0); gpio_set_value(set1_gpio, 1); } #endif//SLEEP_CPUFREQ_MANUAL_SET #else//SLEEP_CPUFREQ_CONSERVATIVE cpufreq_direct_set_policy(0, "userspace"); cpufreq_direct_store_scaling_setspeed(0, "800000", 0); #endif//SLEEP_CPUFREQ_CONSERVATIVE #endif//CONFIG_CPU_FREQ printk(KERN_INFO "PM: Syncing filesystems ... "); sys_sync(); printk("done.\n"); pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]); error = suspend_prepare(); if (error) goto Unlock; if (suspend_test(TEST_FREEZER)) goto Finish; pr_debug("PM: Entering %s sleep\n", pm_states[state]); error = suspend_devices_and_enter(state); Finish: pr_debug("PM: Finishing wakeup.\n"); suspend_finish(); Unlock: mutex_unlock(&pm_mutex); #ifdef CONFIG_CPU_FREQ #ifdef SLEEP_CPUFREQ_CONSERVATIVE #ifdef SLEEP_CPUFREQ_MANUAL_SET if(userSpaceGovernor) { s5pc110_pm_target(g_cpuspeed); printk("recover userspace cpu speed %d \n",g_cpuspeed); g_cpuspeed=0; userSpaceGovernor=false; } if(gbGovernorTransition) { s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_5); gbGovernorTransition=false; } #else//SLEEP_CPUFREQ_MANUAL_SET // change cpufreq to original one if(gbGovernorTransition) { s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_5); gbGovernorTransition = false; } #endif//SLEEP_CPUFREQ_MANUAL_SET #else//SLEEP_CPUFREQ_CONSERVATIVE cpufreq_direct_set_policy(0, "conservative"); #endif//SLEEP_CPUFREQ_CONSERVATIVE #endif//CONFIG_CPU_FREQ return error; }
int enter_state(suspend_state_t state) { int error; struct cpufreq_policy policy; if (!valid_state(state)) return -ENODEV; if (!mutex_trylock(&pm_mutex)) return -EBUSY; #ifdef CONFIG_CPU_FREQ #if 1 // change cpufreq governor to performance // if conservative governor if(is_userspace_gov()) { g_cpuspeed = s5pc110_getspeed(0); printk("userspace cpu speed %d \n",g_cpuspeed); userSpaceGovernor=true; } else if(is_conservative_gov()) { /*Fix the upper transition scaling*/ g_dvfs_fix_lock_limit = true; #if MAXIMUM_FREQ == 1200000 s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_7, LEV_800MHZ); #else s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_7, LEV_832MHZ); #endif gbClockFix = true; error = cpufreq_get_policy(&policy, 0); if(error) { printk("Failed to get policy\n"); goto Unlock; } cpufreq_driver_target(&policy, 800000, CPUFREQ_RELATION_L); } #else // cpufreq_direct_set_policy(0, "userspace"); // cpufreq_direct_store_scaling_setspeed(0, "800000", 0); #endif #endif printk(KERN_INFO "PM: Syncing filesystems ... "); sys_sync(); printk("done.\n"); pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]); error = suspend_prepare(); if (error) goto Unlock; if (suspend_test(TEST_FREEZER)) goto Finish; pr_debug("PM: Entering %s sleep\n", pm_states[state]); error = suspend_devices_and_enter(state); Finish: pr_debug("PM: Finishing wakeup.\n"); suspend_finish(); Unlock: mutex_unlock(&pm_mutex); #ifdef CONFIG_CPU_FREQ #if 1 if(userSpaceGovernor) { s5pc110_pm_target(g_cpuspeed); printk("recover userspace cpu speed %d \n",g_cpuspeed); g_cpuspeed=0; userSpaceGovernor=false; } // change cpufreq to original one if(gbClockFix) { g_dvfs_fix_lock_limit = false; s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_7); gbClockFix = false; } #else // cpufreq_direct_set_policy(0, "conservative"); #endif #endif return error; }
void s5p_handle_cable(void) { char env_buf[120]; char *envp[2]; int env_offset = 0; #if defined (CONFIG_S5PC110_DEMPSEY_BOARD) //MHL v1 //NAGSM_Android_SEL_Kernel_Aakash_20101130 #else if(s5ptv_status.tvout_param.out_mode != TVOUT_OUTPUT_HDMI && s5ptv_status.tvout_param.out_mode != TVOUT_OUTPUT_HDMI_RGB) return; #endif bool previous_hpd_status = s5ptv_status.hpd_status; #ifdef CONFIG_HDMI_HPD s5ptv_status.hpd_status= s5p_hpd_get_state(); #else return; #endif memset(env_buf, 0, sizeof(env_buf)); if(previous_hpd_status == s5ptv_status.hpd_status) { BASEPRINTK("same hpd_status value: %d\n", previous_hpd_status); return; } if(s5ptv_status.hpd_status) { BASEPRINTK("\n hdmi cable is connected \n"); if(s5ptv_status.suspend_status) return; #if 0 #ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_MAX_FREQ_1GHZ // 2010.3.9. s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_4, 3); #else s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_4, 2); #endif #endif #endif #ifdef CONFIG_PM_PWR_GATING s5p_tv_clk_gate( true ); tv_phy_power( true ); #endif /* tv on */ if ( s5ptv_status.tvout_output_enable ) _s5p_tv_if_start(); /* video layer start */ if ( s5ptv_status.vp_layer_enable ) _s5p_vlayer_start(); /* grp0 layer start */ if ( s5ptv_status.grp_layer_enable[0] ) _s5p_grp_start(VM_GPR0_LAYER); /* grp1 layer start */ if ( s5ptv_status.grp_layer_enable[1] ) _s5p_grp_start(VM_GPR1_LAYER); sprintf(env_buf, "HDMI_STATE=online"); envp[env_offset++] = env_buf; envp[env_offset] = NULL; kobject_uevent_env(&(s5p_tvout[0].dev.kobj), KOBJ_CHANGE, envp); } else{ BASEPRINTK("\n hdmi cable is disconnected \n"); if(s5ptv_status.suspend_status) return; sprintf(env_buf, "HDMI_STATE=offline"); envp[env_offset++] = env_buf; envp[env_offset] = NULL; kobject_uevent_env(&(s5p_tvout[0].dev.kobj), KOBJ_CHANGE, envp); if ( s5ptv_status.vp_layer_enable ) { _s5p_vlayer_stop(); s5ptv_status.vp_layer_enable = true; } /* grp0 layer stop */ if ( s5ptv_status.grp_layer_enable[0] ) { _s5p_grp_stop(VM_GPR0_LAYER); s5ptv_status.grp_layer_enable[VM_GPR0_LAYER] = true; } /* grp1 layer stop */ if ( s5ptv_status.grp_layer_enable[1] ) { _s5p_grp_stop(VM_GPR1_LAYER); s5ptv_status.grp_layer_enable[VM_GPR0_LAYER] = true; } /* tv off */ if ( s5ptv_status.tvout_output_enable ) { _s5p_tv_if_stop(); s5ptv_status.tvout_output_enable = true; s5ptv_status.tvout_param_available = true; } #ifdef CONFIG_PM_PWR_GATING /* clk & power off */ s5p_tv_clk_gate( false ); tv_phy_power( false ); #endif #if 0 #ifdef CONFIG_CPU_FREQ s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_4); #endif #endif } }
/* * ftn for video */ static int s5p_tv_v_open(struct file *file) { int ret = 0,err; mutex_lock(mutex_for_fo); if (s5ptv_status.tvout_output_enable) { BASEPRINTK("tvout drv. already used !!\n"); ret = -EBUSY; goto drv_used; } #ifdef CONFIG_CPU_S5PV210 #ifdef CONFIG_PM_PWR_GATING if((s5ptv_status.hpd_status) && !(s5ptv_status.suspend_status)) { BASEPRINTK("tv is turned on\n"); #endif #if 0 #ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_MAX_FREQ_1GHZ // 2010.3.9. if((s5ptv_status.hpd_status)) s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_4, 3); #else if((s5ptv_status.hpd_status)) s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_4, 2); #endif #endif #endif #if defined(CONFIG_S5PC110_SIDEKICK_BOARD) err = gpio_request(S5PV210_GPJ3(1),"EAR_SEL"); udelay(50); gpio_direction_output(S5PV210_GPJ3(1),0); gpio_set_value(S5PV210_GPJ3(1),0); udelay(50); #elif defined(CONFIG_S5PC110_DEMPSEY_BOARD) //there is no connected pin #else err = gpio_request(S5PV210_GPJ4(4),"TV_EN"); udelay(50); gpio_direction_output(S5PV210_GPJ4(4),1); gpio_set_value(S5PV210_GPJ4(4),1); udelay(50); err = gpio_request(S5PV210_GPJ2(6),"EAR_SEL"); udelay(50); gpio_direction_output(S5PV210_GPJ2(6),0); gpio_set_value(S5PV210_GPJ2(6),0); udelay(50); #endif s5p_tv_clk_gate( true ); tv_phy_power( true ); #ifdef CONFIG_PM_PWR_GATING } else BASEPRINTK("tv is off\n"); #endif #endif _s5p_tv_if_init_param(); s5p_tv_v4l2_init_param(); mutex_unlock(mutex_for_fo); /* c110 test */ //s5ptv_status.hpd_status = true; printk("\n\nTV open success\n\n"); #ifdef I2C_BASE mutex_lock(mutex_for_i2c); /* for ddc(hdcp port) */ if(s5ptv_status.hpd_status) { if (i2c_add_driver(&hdcp_i2c_driver)) BASEPRINTK("HDCP port add failed\n"); hdcp_i2c_drv_state = true; } else hdcp_i2c_drv_state = false; mutex_unlock(mutex_for_i2c); /* for i2c probing */ udelay(100); #endif return 0; drv_used: mutex_unlock(mutex_for_fo); return ret; }
static int mfc_open(struct inode *inode, struct file *file) { mfc_inst_ctx *mfc_ctx; int ret; //struct sched_param param = { .sched_priority = 1 }; printk("%s(%d)\n", __func__, __LINE__); mutex_lock(&mfc_mutex); if (!mfc_is_running()) { #ifdef CONFIG_CPU_FREQ #if defined(CONFIG_MACH_S5PC110_P1) s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_1, 2); // DVFS Limit 200Mhz when mfc is running #endif #if defined(CONFIG_MACH_S5PC110_ARIES) #if MAXIMUM_FREQ == 1200000 s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_1, LEV_400MHZ); #else s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_1, LEV_416MHZ); #endif #endif // CONFIG_MACH_S5PC110_P1 #endif #ifdef CONFIG_S5PC11X_LPAUDIO s5pc110_set_lpaudio_lock(1); #endif /* CONFIG_S5PC11X_LPAUDIO */ clk_enable(mfc_clk); #ifdef CONFIG_PM_PWR_GATING s5pc110_lock_power_domain(MFC_DOMAIN_LOCK_TOKEN); #endif if (mfc_init_hw() != TRUE) { #if Frame_Base_Power_CTR_ON clk_disable(mfc_clk); #endif ret = -ENODEV; goto out_open; } #if Frame_Base_Power_CTR_ON clk_disable(mfc_clk); #endif } mfc_ctx = (mfc_inst_ctx *)kmalloc(sizeof(mfc_inst_ctx), GFP_KERNEL); if (mfc_ctx == NULL) { mfc_err("MFCINST_MEMORY_ALLOC_FAIL\n"); ret = -ENOMEM; goto out_open; } memset(mfc_ctx, 0, sizeof(mfc_inst_ctx)); /* get the inst no allocating some part of memory among reserved memory */ mfc_ctx->mem_inst_no = mfc_get_mem_inst_no(); mfc_ctx->InstNo = -1; if (mfc_ctx->mem_inst_no < 0) { mfc_err("MFCINST_INST_NUM_EXCEEDED\n"); kfree(mfc_ctx); ret = -EPERM; goto out_open; } if (mfc_set_state(mfc_ctx, MFCINST_STATE_OPENED) < 0) { mfc_err("MFCINST_ERR_STATE_INVALID\n"); kfree(mfc_ctx); ret = -ENODEV; goto out_open; } /* Decoder only */ mfc_ctx->extraDPB = MFC_MAX_EXTRA_DPB; mfc_ctx->FrameType = MFC_RET_FRAME_NOT_SET; file->private_data = (mfc_inst_ctx *)mfc_ctx; //sched_setscheduler(current, SCHED_FIFO, ¶m); ret = 0; out_open: mutex_unlock(&mfc_mutex); if(ret != 0) { mfc_err("MFC_OEPN_FAIL..... ret(%d) \n", ret); return ret; } #if ENABLE_MFC_DD_MONITOR mfc_info("MFC_OEPN_OK..... ret(%d) \n", ret); #endif return ret; }