fix White screen when power_on or resume
authorzyw <zyw@rock-chips.com>
Tue, 31 May 2011 09:06:17 +0000 (17:06 +0800)
committerzyw <zyw@rock-chips.com>
Tue, 31 May 2011 09:06:29 +0000 (17:06 +0800)
arch/arm/mach-rk29/board-rk29sdk.c
arch/arm/mach-rk29/include/mach/board.h
drivers/video/rk29_fb.c

index ef07c74616c7017d6de4008da069330c1968dde9..647e7edef77ef758a335694d77ca087990d2baac 100755 (executable)
@@ -169,7 +169,7 @@ struct rk29_nand_platform_data rk29_nand_data = {
 * author: zyw@rock-chips.com
 *****************************************************************************************/
 #define FB_ID                       0
-#define FB_DISPLAY_ON_PIN           RK29_PIN6_PD0
+#define FB_DISPLAY_ON_PIN           INVALID_GPIO// RK29_PIN6_PD0
 #define FB_LCD_STANDBY_PIN          RK29_PIN6_PD1
 #define FB_LCD_CABC_EN_PIN          RK29_PIN6_PD2
 #define FB_MCU_FMK_PIN              INVALID_GPIO
@@ -197,6 +197,33 @@ static struct rk29lcd_info rk29_lcd_info = {
     .io_deinit = rk29_lcd_io_deinit,
 };
 
+int rk29_fb_io_enable(void)
+{
+    if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
+    {
+        gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
+        gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);              
+    }
+    if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
+    {
+        gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
+        gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);             
+    }
+}
+
+int rk29_fb_io_disable(void)
+{
+    if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
+    {
+        gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
+        gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);              
+    }
+    if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
+    {
+        gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
+        gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);             
+    }
+}
 
 static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
 {
@@ -270,19 +297,20 @@ static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
         gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
         gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
     }
+    
+    rk29_fb_io_enable();   //enable it
 
     return ret;
 }
 
+
 static struct rk29fb_info rk29_fb_info = {
     .fb_id   = FB_ID,
-    .disp_on_pin = FB_DISPLAY_ON_PIN,
-    .disp_on_value = FB_DISPLAY_ON_VALUE,
-    .standby_pin = FB_LCD_STANDBY_PIN,
-    .standby_value = FB_LCD_STANDBY_VALUE,
     .mcu_fmk_pin = FB_MCU_FMK_PIN,
     .lcd_info = &rk29_lcd_info,
     .io_init   = rk29_fb_io_init,
+    .io_enable = rk29_fb_io_enable,
+    .io_disable = rk29_fb_io_disable,
 };
 
 /* rk29 fb resource */
@@ -776,13 +804,13 @@ static struct rk29camera_platform_ioctl_cb  sensor_ioctl_cb = {
 #define PWM_GPIO RK29_PIN1_PB5
 #define PWM_EFFECT_VALUE  1
 
-//#define LCD_DISP_ON_PIN
+#define LCD_DISP_ON_PIN
 
 #ifdef  LCD_DISP_ON_PIN
-#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
-#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
+//#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
+//#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
 
-#define BL_EN_PIN         GPIO0L_GPIO0A5
+#define BL_EN_PIN         RK29_PIN6_PD0
 #define BL_EN_VALUE       GPIO_HIGH
 #endif
 static int rk29_backlight_io_init(void)
@@ -791,7 +819,7 @@ static int rk29_backlight_io_init(void)
 
     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
        #ifdef  LCD_DISP_ON_PIN
-    rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
+   // rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
 
     ret = gpio_request(BL_EN_PIN, NULL);
     if(ret != 0)
@@ -812,6 +840,7 @@ static int rk29_backlight_io_deinit(void)
     gpio_free(BL_EN_PIN);
     #endif
     rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
+    
     return ret;
 }
 
@@ -824,6 +853,10 @@ static int rk29_backlight_pwm_suspend(void)
                return -1;
        }
        gpio_direction_output(PWM_GPIO, GPIO_LOW);
+   #ifdef  LCD_DISP_ON_PIN
+    gpio_direction_output(BL_EN_PIN, 0);
+    gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
+   #endif
        return ret;
 }
 
@@ -831,6 +864,12 @@ static int rk29_backlight_pwm_resume(void)
 {
        gpio_free(PWM_GPIO);
        rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
+
+    #ifdef  LCD_DISP_ON_PIN
+    msleep(30);
+    gpio_direction_output(BL_EN_PIN, 1);
+    gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
+    #endif
        return 0;
 }
 
index a761ee53520e02d8c2d5959edeb77de3b8e83048..b9e59e90ee59363666cd5ef51756953a75fe44a7 100755 (executable)
@@ -69,14 +69,12 @@ struct rk29_fb_setting_info{
 
 struct rk29fb_info{
     u32 fb_id;
-    u32 disp_on_pin;
-    u8 disp_on_value;
-    u32 standby_pin;
-    u8 standby_value;
     u32 mcu_fmk_pin;
     struct rk29lcd_info *lcd_info;
     int (*io_init)(struct rk29_fb_setting_info *fb_setting);
     int (*io_deinit)(void);
+    int (*io_enable)(void);
+    int (*io_disable)(void);
 };
 
 struct rk29_bl_info{
index 2bc6c7783574ab0a79cd54ec9631a1e56304e7d3..cf5c0bea5a6765921da836c86f06ca9f99e30516 100755 (executable)
@@ -265,34 +265,6 @@ static int new_frame_seted = 1;
 #endif
 static struct wake_lock idlelock; /* only for fb */
 
-void set_lcd_pin(struct platform_device *pdev, int enable)
-{
-       struct rk29fb_info *mach_info = pdev->dev.platform_data;
-
-       unsigned display_on = mach_info->disp_on_pin;
-       unsigned lcd_standby = mach_info->standby_pin;
-
-       int display_on_pol = mach_info->disp_on_value;
-       int lcd_standby_pol = mach_info->standby_value;
-
-       fbprintk(">>>>>> %s : %s \n", __FILE__, __FUNCTION__);
-       fbprintk(">>>>>> display_on(%d) = %d \n", display_on, enable ? display_on_pol : !display_on_pol);
-       fbprintk(">>>>>> lcd_standby(%d) = %d \n", lcd_standby, enable ? lcd_standby_pol : !lcd_standby_pol);
-
-    // set display_on
-
-    if(display_on != INVALID_GPIO)
-    {
-        gpio_direction_output(display_on, 0);
-        gpio_set_value(display_on, enable ? display_on_pol : !display_on_pol);                         
-    }
-    if(lcd_standby != INVALID_GPIO)
-    {
-        gpio_direction_output(lcd_standby, 0);
-                               gpio_set_value(lcd_standby, enable ? lcd_standby_pol : !lcd_standby_pol);                         
-    }
-}
-
 int mcu_do_refresh(struct rk29fb_inf *inf)
 {
     if(inf->mcu_stopflush)  return 0;
@@ -2141,6 +2113,7 @@ int FB_Switch_Screen( struct rk29fb_screen *screen, u32 enable )
 {
     struct rk29fb_inf *inf = platform_get_drvdata(g_pdev);
    // struct rk29fb_info *mach_info = g_pdev->dev.platform_data;
+    struct rk29fb_info *mach_info = g_pdev->dev.platform_data;
 
     memcpy(&inf->panel2_info, screen, sizeof( struct rk29fb_screen ));
 
@@ -2159,8 +2132,10 @@ int FB_Switch_Screen( struct rk29fb_screen *screen, u32 enable )
 
     if(inf->cur_screen->standby)    inf->cur_screen->standby(1);
     // operate the display_on pin to power down the lcd
-    set_lcd_pin(g_pdev, (enable==0));
-
+   
+    if(enable && mach_info->io_disable)mach_info->io_disable();  //close lcd out
+    else if (mach_info->io_enable)mach_info->io_enable();       //open lcd out
+    
     load_screen(inf->fb0, 0);
        mcu_refresh(inf);
 
@@ -2291,6 +2266,7 @@ static void rk29fb_early_suspend(struct early_suspend *h)
                                                early_suspend);
 
     struct rk29fb_inf *inf = info->inf;
+    struct rk29fb_info *mach_info = g_pdev->dev.platform_data;
 
     fbprintk(">>>>>> %s : %s\n", __FILE__, __FUNCTION__);
 
@@ -2299,8 +2275,8 @@ static void rk29fb_early_suspend(struct early_suspend *h)
         return;
     }
 
-    if(inf->cur_screen != &inf->panel2_info)  // close lcd pwr when output screen is lcd
-        set_lcd_pin(g_pdev, 0);
+    if((inf->cur_screen != &inf->panel2_info) && mach_info->io_disable)  // close lcd pwr when output screen is lcd
+       mach_info->io_disable();  //close lcd out 
 
        if(inf->cur_screen->standby)
        {
@@ -2344,6 +2320,7 @@ static void rk29fb_early_resume(struct early_suspend *h)
 
     struct rk29fb_inf *inf = info->inf;
     struct rk29fb_screen *screen = inf->cur_screen;
+    struct rk29fb_info *mach_info = g_pdev->dev.platform_data;
 
     fbprintk(">>>>>> %s : %s\n", __FILE__, __FUNCTION__);
     if(!inf) {
@@ -2381,10 +2358,13 @@ static void rk29fb_early_resume(struct early_suspend *h)
                fbprintk(">>>>>> power on the screen! \n");
                inf->cur_screen->standby(0);
        }
-    msleep(100);
-    if(inf->cur_screen != &inf->panel2_info)  // open lcd pwr when output screen is lcd
-        set_lcd_pin(g_pdev, 1);
-       memcpy((u8*)inf->preg, (u8*)&inf->regbak, 0xa4);  //resume reg
+    msleep(10);
+    memcpy((u8*)inf->preg, (u8*)&inf->regbak, 0xa4);  //resume reg
+    msleep(40);
+    
+    if((inf->cur_screen != &inf->panel2_info) && mach_info->io_enable)  // open lcd pwr when output screen is lcd
+       mach_info->io_enable();  //close lcd out 
+               
 }
 
 static struct suspend_info suspend_info = {
@@ -2647,7 +2627,7 @@ static int __init rk29fb_probe (struct platform_device *pdev)
         mach_info->io_init(&fb_setting);
     }
 
-       set_lcd_pin(pdev, 1);
+       //set_lcd_pin(pdev, 1);
        mdelay(10);
        g_pdev = pdev;
        inf->mcu_usetimer = 1;
@@ -2778,7 +2758,8 @@ static int rk29fb_remove(struct platform_device *pdev)
         free_irq(gpio_to_irq(mach_info->mcu_fmk_pin), pdev);
     }
 
-       set_lcd_pin(pdev, 0);
+    if(mach_info->io_disable)  
+       mach_info->io_disable();  //close lcd out 
 
     // blank the lcdc
     if(inf->fb1)
@@ -2842,10 +2823,13 @@ static int rk29fb_remove(struct platform_device *pdev)
 static void rk29fb_shutdown(struct platform_device *pdev)
 {
     struct rk29fb_inf *inf = platform_get_drvdata(pdev);
+    struct rk29fb_info *mach_info = pdev->dev.platform_data;;
 
        fbprintk("----------------------------rk29fb_shutdown----------------------------\n");
 
-    set_lcd_pin(pdev, 0);
+    if(mach_info->io_disable)  
+       mach_info->io_disable();  //close lcd out 
+       
     if(!inf->in_suspend)
     {
         LcdMskReg(inf, DSP_CTRL1, m_BLANK_MODE , v_BLANK_MODE(1));