s32 disp_lcd_post_disable(struct disp_lcd* lcd) { struct disp_lcd_private_data *lcdp = disp_lcd_get_priv(lcd); u32 data[2]; if((NULL == lcd) || (NULL == lcdp)) { DE_WRN("NULL hdl!\n"); return DIS_FAIL; } lcd_clk_disable(lcd); #if defined(__LINUX_PLAT__) { unsigned long flags; spin_lock_irqsave(&lcd_data_lock, flags); #endif lcdp->disabling = 0; lcdp->enabled = 0; #if defined(__LINUX_PLAT__) spin_unlock_irqrestore(&lcd_data_lock, flags); } #endif /* notifier */ data[0] = 0;/* enable */ data[1] = (u32)DISP_OUTPUT_TYPE_LCD; disp_notifier_call_chain(DISP_EVENT_OUTPUT_ENABLE, lcd->channel_id, (void*)data); return 0; }
void MT6302_spiPowerCtrl(kal_bool on) { kal_uint32 i; if(0 == MT6302_getSPIInterface()) { if(31 < MT6302_LCD_pdnHandle) ASSERT(0); if (KAL_FALSE == on) lcd_clk_disable(MT6302_LCD_pdnHandle); else if(KAL_TRUE == on){ lcd_clk_enable(MT6302_LCD_pdnHandle); if(DRVPDN_CON1_LCD & DRV_Reg(DRVPDN_CON1)) ASSERT(0); i = 1000; while(i) i--; } else ASSERT(0); } else if(1 == MT6302_getSPIInterface()) { /*we don't know should we do power control before want to write SPI in GPIO implementation*/ } else{ IMPLEMENTING_ASSERT; } drv_trace8(TRACE_GROUP_4, SIM_GEMINI_GEN1, FILE_MT6302_SPI, __LINE__, on, DRV_Reg(DRVPDN_CON1), MT6302_getSPIInterface(), MT6302_LCD_pdnHandle, drv_get_current_time(), 0 ); }
s32 disp_lcd_init(struct disp_lcd* lcd) { struct disp_lcd_private_data *lcdp = disp_lcd_get_priv(lcd); struct disp_notifier_block *nb; if((NULL == lcd) || (NULL == lcdp)) { DE_WRN("NULL hdl!\n"); return DIS_FAIL; } /* register one notifier for all lcd */ if(0 == lcd->channel_id) { nb = (struct disp_notifier_block *)OSAL_malloc(sizeof(struct disp_notifier_block)); if(nb) { nb->notifier_call = &disp_lcd_notifier_callback; disp_notifier_register(nb); } else DE_WRN("malloc memory fail!\n"); } lcd_get_sys_config(lcd->channel_id, &lcdp->lcd_cfg); lcd_parse_panel_para(lcd->channel_id, &lcdp->panel_info); if(disp_lcd_is_used(lcd)) { if(lcdp->panel_info.lcd_pwm_used) { lcdp->pwm_info.channel = lcdp->panel_info.lcd_pwm_ch; lcdp->pwm_info.polarity = lcdp->panel_info.lcd_pwm_pol; // lcdp->pwm_info.dev = OSAL_Pwm_request(lcdp->panel_info.lcd_pwm_ch); } disp_lcd_backlight_disable(lcd); } lcd_clk_init(lcd); lcd_clk_enable(lcd); disp_al_lcd_init(lcd->channel_id); lcd_clk_disable(lcd); if(disp_al_query_lcd_mod(lcd->channel_id)) { OSAL_RegISR(lcdp->irq_no,0,disp_lcd_event_proc,(void*)lcd->channel_id,0,0); #if !defined(__LINUX_PLAT__) OSAL_InterruptEnable(lcdp->irq_no); #endif } if(LCD_IF_DSI == lcdp->panel_info.lcd_if) { OSAL_RegISR(lcdp->irq_no_dsi,0,disp_lcd_event_proc,(void*)lcd->channel_id,0,0); #if !defined(__LINUX_PLAT__) OSAL_InterruptEnable(lcdp->irq_no_dsi); #endif } else if(LCD_IF_EDP == lcdp->panel_info.lcd_if) { /* todo? register edp vint proc */ } __u64 backlight_bright; __u64 period_ns, duty_ns; if(lcdp->panel_info.lcd_pwm_freq != 0) { period_ns = 1000*1000*1000 / lcdp->panel_info.lcd_pwm_freq; } else { DE_WRN("lcd%d.lcd_pwm_freq is ZERO\n", lcd->channel_id); period_ns = 1000*1000*1000 / 1000; //default 1khz } backlight_bright = lcdp->lcd_cfg.backlight_bright; duty_ns = (backlight_bright * period_ns) / 256; // DE_DBG("[PWM]backlight_bright=%d,period_ns=%d,duty_ns=%d\n",(u32)backlight_bright,(u32)period_ns, (u32)duty_ns); sunxi_pwm_set_polarity(lcdp->pwm_info.channel, lcdp->pwm_info.polarity); sunxi_pwm_config(lcdp->pwm_info.channel, duty_ns, period_ns); lcdp->pwm_info.duty_ns = duty_ns; lcdp->pwm_info.period_ns = period_ns; return 0; }