Skip to content

Commit

Permalink
healthd: Write to blink file to fix LED
Browse files Browse the repository at this point in the history
Many devices (such as bacon) require touching a blink file before
changes to the LED are committed to hardware.

Jira: CYAN-7689

Change-Id: Ia18a62134d196a636352bcd1af924c407c19d5b4
  • Loading branch information
tdmcyngn committed Jul 6, 2016
1 parent dd08664 commit 5d90c85
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions healthd/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ LOCAL_CFLAGS := -D__STDC_LIMIT_MACROS -Werror
HEALTHD_CHARGER_DEFINES := RED_LED_PATH \
GREEN_LED_PATH \
BLUE_LED_PATH \
BLINK_PATH \
BACKLIGHT_PATH \
CHARGING_ENABLED_PATH

Expand Down
27 changes: 27 additions & 0 deletions healthd/healthd_mode_charger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ char *locale;
#define BLUE_LED_PATH "/sys/class/leds/blue/brightness"
#endif

#ifndef BLINK_PATH
#define BLINK_PATH "/sys/class/leds/red/device/blink"
#endif

#define LOGE(x...) do { KLOG_ERROR("charger", x); } while (0)
#define LOGW(x...) do { KLOG_WARNING("charger", x); } while (0)
#define LOGV(x...) do { KLOG_DEBUG("charger", x); } while (0)
Expand Down Expand Up @@ -214,6 +218,26 @@ static int char_height;
static bool minui_inited;

#ifndef NO_CHARGER_LED
static int set_blink(int val)
{
int fd;
char buffer[10];

fd = open(BLINK_PATH, O_RDWR);
if (fd < 0) {
LOGE("Could not open blink file\n");
return -1;
}
snprintf(buffer, sizeof(buffer), "%d\n", val);
if (write(fd, buffer, strlen(buffer)) < 0) {
LOGE("Could not write to blink file\n");
close(fd);
return -1;
}
close(fd);
return 0;
}

static int set_tricolor_led(int on, int color)
{
int fd, i;
Expand Down Expand Up @@ -258,6 +282,9 @@ static int set_battery_soc_leds(int soc)
LOGV("soc = %d, set led color 0x%x\n", soc, soc_leds[i].color);
}

/* This is required to commit the changes to hardware */
set_blink(0);

return 0;
}
#endif
Expand Down

0 comments on commit 5d90c85

Please sign in to comment.