void acc_con_intr_handle(struct work_struct *_work) { //ACC_CONDEV_DBG(""); //check the flag MHL or keyboard int cur_state = gpio_get_value(GPIO_ACCESSORY_INT); if(cur_state !=DOCK_STATE) { if(1==cur_state) { ACC_CONDEV_DBG("docking station detatched!!!"); DOCK_STATE = cur_state; #if defined(CONFIG_KEYBOARD_P1) check_keyboard_dock(); #endif #ifdef CONFIG_MHL_SII9234 //call MHL deinit MHD_HW_Off(); //msleep(120); //max8998_ldo3_8_control(0,LDO_TV_OUT); //ldo 3,8 off //printk("%s: LDO3_8 is disabled by TV \n", __func__); TVout_LDO_ctrl(false); #endif acc_dock_check(CONNECTED_DOCK , DOCK_STATE); CONNECTED_DOCK = 0; } else if(0==cur_state) { ACC_CONDEV_DBG("docking station attatched!!!"); DOCK_STATE = cur_state; #if defined(CONFIG_KEYBOARD_P1) if(check_keyboard_dock()) { CONNECTED_DOCK = DOCK_KEYBD; } else #endif { #ifdef CONFIG_MHL_SII9234 CONNECTED_DOCK = DOCK_DESK; //max8998_ldo3_8_control(1,LDO_TV_OUT); //ldo 3,8 on //printk("%s: LDO3_8 is enabled by TV \n", __func__); //msleep(120); TVout_LDO_ctrl(true); //call MHL init sii9234_tpi_init(); #endif } acc_dock_check(CONNECTED_DOCK , DOCK_STATE); } } else { ACC_CONDEV_DBG("Ignored"); } enable_irq(IRQ_ACCESSORY_INT); }
static ssize_t MHD_check_read(struct device *dev, struct device_attribute *attr, char *buf) { int count; int res; TVout_LDO_ctrl(true); if(!MHD_HW_IsOn()) { sii9234_tpi_init(); res = MHD_Read_deviceID(); MHD_HW_Off(); } else { sii9234_tpi_init(); res = MHD_Read_deviceID(); } count = sprintf(buf,"%d\n", res ); TVout_LDO_ctrl(false); return count; }
/* * Remove */ static int s5p_tv_remove(struct platform_device *pdev) { __s5p_hdmi_release(pdev); __s5p_sdout_release(pdev); __s5p_mixer_release(pdev); __s5p_vp_release(pdev); #ifdef I2C_BASE i2c_del_driver(&hdcp_i2c_driver); #endif clk_disable(s5ptv_status.tvenc_clk); clk_disable(s5ptv_status.vp_clk); clk_disable(s5ptv_status.mixer_clk); clk_disable(s5ptv_status.hdmi_clk); clk_disable(s5ptv_status.sclk_hdmi); clk_disable(s5ptv_status.sclk_mixer); clk_disable(s5ptv_status.sclk_dac); clk_put(s5ptv_status.tvenc_clk); clk_put(s5ptv_status.vp_clk); clk_put(s5ptv_status.mixer_clk); clk_put(s5ptv_status.hdmi_clk); clk_put(s5ptv_status.sclk_hdmi); clk_put(s5ptv_status.sclk_mixer); clk_put(s5ptv_status.sclk_dac); clk_put(s5ptv_status.sclk_pixel); clk_put(s5ptv_status.sclk_hdmiphy); free_irq(IRQ_MIXER, pdev); free_irq(IRQ_HDMI, pdev); free_irq(IRQ_TVENC, pdev); mutex_destroy(mutex_for_fo); #ifdef I2C_BASE mutex_destroy(mutex_for_i2c); #endif TVout_LDO_ctrl(false); return 0; }
int s5p_tv_v_release(struct file *filp) { TVout_LDO_ctrl(true); #if defined(CONFIG_CPU_S5PV210) && defined(CONFIG_PM) if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_DVI) tv_phy_power( false ); if((s5ptv_status.hpd_status) && !(s5ptv_status.suspend_status)) { #endif if(s5ptv_status.vp_layer_enable) _s5p_vlayer_stop(); if(s5ptv_status.tvout_output_enable) _s5p_tv_if_stop(); #if defined(CONFIG_CPU_S5PV210) && defined(CONFIG_PM) }else s5ptv_status.vp_layer_enable = false; #endif s5ptv_status.hdcp_en = false; s5ptv_status.tvout_output_enable = false; /* * drv. release * - just check drv. state reg. or not. */ #ifdef I2C_BASE mutex_lock(mutex_for_i2c); if (hdcp_i2c_drv_state) { i2c_del_driver(&hdcp_i2c_driver); hdcp_i2c_drv_state = false; } mutex_unlock(mutex_for_i2c); #endif s5p_tv_clk_gate(false); #ifdef CONFIG_CPU_S5PV210 #ifdef CONFIG_PM if((s5ptv_status.hpd_status) && !(s5ptv_status.suspend_status)) { #endif //s5p_tv_clk_gate(false); //if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB) //tv_phy_power( false ); #ifdef CONFIG_CPU_FREQ_S5PV210 if(s5ptv_status.hpd_status) s5pv210_set_cpufreq_level(NORMAL_TABLE); #endif /* CONFIG_CPU_FREQ_S5PV210 */ #ifdef CONFIG_PM } #endif #endif Isdrv_open = 0; TVout_LDO_ctrl(false); printk("[TVOUT]s5p_tv_v_release --\n"); return 0; }
/* * ftn for video */ static int s5p_tv_v_open(struct file *file) { int ret = 0; printk("[TVOUT]s5p_tv_v_open ++\n"); TVout_LDO_ctrl(true); Isdrv_open = 1; mutex_lock(mutex_for_fo); if (s5ptv_status.tvout_output_enable) { BASEPRINTK("tvout drv. already used !!\n"); ret = -EBUSY; goto drv_used; } s5p_tv_clk_gate( true ); #ifdef CONFIG_CPU_S5PV210 #ifdef CONFIG_PM if((s5ptv_status.hpd_status) && !(s5ptv_status.suspend_status)) { BASEPRINTK("tv is turned on\n"); #endif #ifdef CONFIG_CPU_FREQ_S5PV210 if((s5ptv_status.hpd_status)) s5pv210_set_cpufreq_level(RESTRICT_TABLE); #endif /* CONFIG_CPU_FREQ_S5PV210 */ //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 ); #ifdef CONFIG_PM } else BASEPRINTK("tv is off\n"); #endif #endif _s5p_tv_if_init_param(); s5p_tv_v4l2_init_param(); mutex_unlock(mutex_for_fo); #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 //if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB) tv_phy_power( true ); return 0; drv_used: mutex_unlock(mutex_for_fo); return ret; }
void s5p_handle_cable(void) { char env_buf[120]; char *envp[2]; int env_offset = 0; #if 0 if(s5ptv_status.tvout_param.out_mode != TVOUT_OUTPUT_HDMI && s5ptv_status.tvout_param.out_mode != TVOUT_OUTPUT_HDMI_RGB) return; #endif int previous_hpd_status = s5ptv_status.hpd_status; #ifdef CONFIG_HDMI_HPD if (s5p_hpd_get_state()) { s5ptv_status.hpd_status = 1; set_irq_type(IRQ_EINT13, IRQ_TYPE_EDGE_FALLING); if (suspend_resume_sync == 2) suspend_resume_sync = 0; } else { s5ptv_status.hpd_status = 0; set_irq_type(IRQ_EINT13, IRQ_TYPE_EDGE_RISING); } // s5ptv_status.hpd_status= gpio_get_value(S5PV210_GPH1(5)); #else return; #endif printk(KERN_INFO "HDMI handle_cable previous status is %d and current status is %d\n",previous_hpd_status,s5ptv_status.hpd_status); 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) { TVout_LDO_ctrl(true); BASEPRINTK("\n hdmi cable is connected \n"); 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); if(s5ptv_status.suspend_status) { printk("[TVOUT]hdmi cable is connected Before Suspend \n"); return; } #ifdef CONFIG_CPU_FREQ_S5PV210 s5pv210_set_cpufreq_level(RESTRICT_TABLE); #endif /* CONFIG_CPU_FREQ_S5PV210 */ 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 ); #ifdef CONFIG_PM #if 0 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 #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); printk("[TVOUT]hdmi cable is connected\n"); } else{ BASEPRINTK("\n hdmi cable is disconnected \n"); #if 1 if(s5ptv_status.suspend_status || suspend_resume_sync == 2) { //if(gpio_get_value(GPIO_ACCESSORY_INT)) { s5p_tv_clk_gate( true ); tv_phy_power( true ); } //else // return; } #endif // if (!s5ptv_status.suspend_status) { if (suspend_resume_sync == 0) { 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 = false; s5ptv_status.tvout_param_available = false; } #ifdef CONFIG_PM /* clk & power off */ s5p_tv_clk_gate( false ); //if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB) // tv_phy_power( false ); #endif } 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); printk("[TVOUT]hdmi cable is disconnected\n"); #ifdef CONFIG_CPU_FREQ_S5PV210 if (suspend_resume_sync == 0) s5pv210_set_cpufreq_level(NORMAL_TABLE); #endif /* CONFIG_CPU_FREQ_S5PV210 */ } }
/* * Suspend */ int s5p_tv_early_suspend(struct platform_device *dev, pm_message_t state) { BASEPRINTK("(hpd_status = %d)++\n", s5ptv_status.hpd_status); mutex_lock(mutex_for_fo); s5ptv_status.suspend_status = true; suspend_resume_sync = 1; printk(KERN_INFO "s5p_tv_early suspend executing..\n"); #ifdef CABLE_CHECK //s5p_hpd_set_state(HPD_SLEEP); if (s5p_hpd_get_state()) { hpd_sleep_state = 0; set_irq_type(IRQ_EINT13, IRQ_TYPE_EDGE_FALLING); } else { hpd_sleep_state = 1; set_irq_type(IRQ_EINT13, IRQ_TYPE_EDGE_RISING); } #endif if(!(s5ptv_status.hpd_status)) { printk(KERN_INFO "s5p_tv_early_suspend returned no HDMI connected\n"); mutex_unlock(mutex_for_fo); return 0; } else { IsPower_on = false; TVout_LDO_ctrl(true); /* video layer stop */ 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; } if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_DVI) tv_phy_power( false ); /* tv off */ if ( s5ptv_status.tvout_output_enable ) { _s5p_tv_if_stop(); s5ptv_status.tvout_output_enable = true; s5ptv_status.tvout_param_available = true; } /* clk & power off */ s5p_tv_clk_gate( false ); #ifdef CONFIG_CPU_FREQ_S5PV210 s5pv210_set_cpufreq_level(NORMAL_TABLE); #endif /* CONFIG_CPU_FREQ_S5PV210 */ } mutex_unlock(mutex_for_fo); BASEPRINTK("()--\n"); return 0; }
void acc_notified(int acc_adc) { char env_buf[60]; char stat_buf[60]; char *envp[3]; int env_offset = 0; memset(env_buf, 0, sizeof(env_buf)); memset(stat_buf, 0, sizeof(stat_buf)); if(acc_adc != false) { if((2150<acc_adc) && (2350>acc_adc)) { sprintf(env_buf, "ACCESSORY=TV"); CONNECTED_ACC = ACC_TVOUT; } else if((1150<acc_adc) && (1350>acc_adc)) { sprintf(env_buf, "ACCESSORY=lineout"); CONNECTED_ACC = ACC_LINEOUT; } else if((1650<acc_adc) && (1850>acc_adc)) { sprintf(env_buf, "ACCESSORY=carmount"); CONNECTED_ACC = ACC_CARMOUNT; } else { sprintf(env_buf, "ACCESSORY=unknown"); CONNECTED_ACC = 0; } sprintf(stat_buf, "STATE=online"); envp[env_offset++] = env_buf; envp[env_offset++] = stat_buf; envp[env_offset] = NULL; if(CONNECTED_ACC == ACC_TVOUT) { //max8998_ldo3_8_control(1,LDO_TV_OUT); //ldo 3,8 on //printk("%s: LDO3_8 is enabled by TV \n", __func__); //msleep(100); TVout_LDO_ctrl(true); } kobject_uevent_env(&acc_dev->kobj, KOBJ_CHANGE, envp); ACC_CONDEV_DBG("%s : %s",env_buf,stat_buf); } else { if(CONNECTED_ACC == ACC_TVOUT) sprintf(env_buf, "ACCESSORY=TV"); else if(CONNECTED_ACC == ACC_LINEOUT) sprintf(env_buf, "ACCESSORY=lineout"); else if(CONNECTED_ACC == ACC_CARMOUNT) sprintf(env_buf, "ACCESSORY=carmount"); else sprintf(env_buf, "ACCESSORY=unknown"); sprintf(stat_buf, "STATE=offline"); envp[env_offset++] = env_buf; envp[env_offset++] = stat_buf; envp[env_offset] = NULL; kobject_uevent_env(&acc_dev->kobj, KOBJ_CHANGE, envp); if(CONNECTED_ACC == ACC_TVOUT) { //msleep(200); //max8998_ldo3_8_control(0,LDO_TV_OUT); //ldo 3,8 off //printk("%s: LDO3_8 is disabled by TV \n", __func__); TVout_LDO_ctrl(false); } ACC_CONDEV_DBG("%s : %s",env_buf,stat_buf); } }
/* * 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; suspend_resume_sync = 2; #ifdef CABLE_CHECK hpd_sleep_state =0; #endif printk(KERN_INFO "s5p_tv_late_resume executing...\n"); if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_DVI) { s5p_handle_cable(); } if(!(s5ptv_status.hpd_status)) { mutex_unlock(mutex_for_fo); return 0; } else { #ifdef CONFIG_CPU_FREQ_S5PV210 s5pv210_set_cpufreq_level(RESTRICT_TABLE); #endif /* CONFIG_CPU_FREQ_S5PV210 */ /* clk & power on */ TVout_LDO_ctrl(true); 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 || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_DVI)&&(s5ptv_status.hpd_status == HPD_HI)) tv_phy_power(true); /* 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; }