backlight:support fb_blank operation
authorlw@rock-chips.com <lw@rock-chips.com>
Thu, 23 Aug 2012 10:34:43 +0000 (18:34 +0800)
committerlw <lw@rock-chips.com>
Thu, 23 Aug 2012 10:35:47 +0000 (18:35 +0800)
drivers/video/backlight/rk29_backlight.c

index ee8cd6047856b8255ec6cc3a8a5ee1070ff38fb8..4244e385340c0631c7795e83ee6a910291e416ad 100755 (executable)
@@ -96,22 +96,32 @@ static int rk29_bl_update_status(struct backlight_device *bl)
        struct rk29_bl_info *rk29_bl_info = bl_get_data(bl);
        u32 id = rk29_bl_info->pwm_id;
        u32 ref = rk29_bl_info->bl_ref;
-
+       int brightness = bl->props.brightness;
+       
        if (suspend_flag)
-               return 0;
+               return 0;       
+
+       if (bl->props.power != FB_BLANK_UNBLANK)
+               brightness = 0;
+
+       if (bl->props.fb_blank != FB_BLANK_UNBLANK)
+               brightness = 0; 
+
+       if (bl->props.state & BL_CORE_SUSPENDED)
+               brightness = 0;
 
        if (bl->props.brightness < rk29_bl_info->min_brightness)        /*avoid can't view screen when close backlight*/
-               bl->props.brightness = rk29_bl_info->min_brightness;
+               brightness = rk29_bl_info->min_brightness;
 
        div_total = read_pwm_reg(id, PWM_REG_LRC);
        if (ref) {
-               divh = div_total*(bl->props.brightness)/BL_STEP;
+               divh = div_total*brightness/BL_STEP;
        } else {
-               divh = div_total*(BL_STEP-bl->props.brightness)/BL_STEP;
+               divh = div_total*(BL_STEP-brightness)/BL_STEP;
        }
        write_pwm_reg(id, PWM_REG_HRC, divh);
 
-       DBG(">>>%s-->%d brightness = %d, div_total = %d, divh = %d\n",__FUNCTION__,__LINE__,bl->props.brightness, div_total, divh);
+       DBG("%s:line=%d,brightness = %d, div_total = %d, divh = %d\n",__FUNCTION__,__LINE__,brightness, div_total, divh);
        return 0;
 }