Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e961c04 authored by Fenglin Wu's avatar Fenglin Wu Committed by Steve Kondik
Browse files

healthd: charger: Add backlight control in charging animation

On some targets the FBIOBLANK does not control the backlight. Add the
backlight control in charging animation to make sure the backlight will
be turned on/off successfully.

Change-Id: I3bba3b58daba6cffa4eb1314a6da1542f43e8e47
parent 19cc4a3e
Loading
Loading
Loading
Loading
+36 −2
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ char *locale;
#define RED_LED_PATH            "/sys/class/leds/red/brightness"
#define GREEN_LED_PATH          "/sys/class/leds/green/brightness"
#define BLUE_LED_PATH           "/sys/class/leds/blue/brightness"
#define BACKLIGHT_PATH          "/sys/class/leds/lcd-backlight/brightness"

#define LOGE(x...) do { KLOG_ERROR("charger", x); } while (0)
#define LOGI(x...) do { KLOG_INFO("charger", x); } while (0)
@@ -268,6 +269,37 @@ static int set_battery_soc_leds(int soc)
    return 0;
}

#define BACKLIGHT_ON_LEVEL    100
static int set_backlight_on(void)
{
    int fd;
    char buffer[10];

    if (access(BACKLIGHT_PATH, R_OK | W_OK) != 0)
    {
        LOGI("Backlight control not support\n");
        return 0;
    }

    memset(buffer, '\0', sizeof(buffer));
    fd = open(BACKLIGHT_PATH, O_RDWR);
    if (fd < 0) {
        LOGE("Could not open backlight node : %s\n", strerror(errno));
        goto cleanup;
    }
    LOGV("Enabling backlight\n");
    snprintf(buffer, sizeof(buffer), "%d\n", BACKLIGHT_ON_LEVEL);
    if (write(fd, buffer,strlen(buffer)) < 0) {
        LOGE("Could not write to backlight node : %s\n", strerror(errno));
        goto cleanup;
    }
cleanup:
    if (fd >= 0)
        close(fd);

    return 0;
}

/* current time in milliseconds */
static int64_t curr_time_ms(void)
{
@@ -525,8 +557,10 @@ static void update_screen_state(struct charger *charger, int64_t now)
    }

    /* unblank the screen on first cycle */
    if (batt_anim->cur_cycle == 0)
    if (batt_anim->cur_cycle == 0) {
        set_backlight_on();
        gr_fb_blank(false);
    }

    /* draw the new frame (@ cur_frame) */
    redraw_screen(charger);