Add support for Notification LED in power OFF mode [1/2]
Issue: FP3-A11#203
Issue: FP3-A11#233
Change-Id: I3816c7320d6eb544d911a9b26d4b022ff4c27a69
diff --git a/liblight/lights.c b/liblight/lights.c
index e20c1ab..c9cbaaf 100644
--- a/liblight/lights.c
+++ b/liblight/lights.c
@@ -38,6 +38,26 @@
#define DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS 0x80
#endif
+#if defined( ARIMA_DEBUG )
+ #undef ARIMA_DEBUG
+#endif
+ #define ARIMA_DEBUG 0
+
+#if defined( PNX )
+ #undef PNX
+#endif
+#define PNX "[ARIMA]"
+
+#if defined( LIGHT_DBG )
+ #undef LIGHT_DBG
+#endif
+
+#if( ARIMA_DEBUG )
+ #define LIGHT_DBG(fmt,args...) ALOGE(PNX "[%s] " fmt,__FUNCTION__,##args)
+#else
+ #define LIGHT_DBG(fmt,args...) do{}while(0)
+#endif
+
/******************************************************************************/
static pthread_once_t g_init = PTHREAD_ONCE_INIT;
@@ -65,6 +85,18 @@
char const*const BUTTON_FILE
= "/sys/class/leds/button-backlight/brightness";
+#if( 1 )
+
+char const*const RED_BLINK_FILE
+ = "/sys/class/leds/red/breath";
+
+char const*const GREEN_BLINK_FILE
+ = "/sys/class/leds/green/breath";
+
+char const*const BLUE_BLINK_FILE
+ = "/sys/class/leds/blue/breath";
+
+#else /* Default */
char const*const RED_BLINK_FILE
= "/sys/class/leds/red/blink";
@@ -74,6 +106,37 @@
char const*const BLUE_BLINK_FILE
= "/sys/class/leds/blue/blink";
+#endif /* End.. */
+
+#if defined( LED_DELAY_FUNC_USAGE )
+ #undef LED_DELAY_FUNC_USAGE
+#endif
+#define LED_DELAY_FUNC_USAGE 0
+
+#if( LED_DELAY_FUNC_USAGE )
+char const*const RED_DELAY_ON_FILE
+ = "/sys/class/leds/red/delay_on";
+
+char const*const RED_DELAY_OFF_FILE
+ = "/sys/class/leds/red/delay_off";
+
+char const*const GREEN_DELAY_ON_FILE
+ = "/sys/class/leds/green/delay_on";
+
+char const*const GREEN_DELAY_OFF_FILE
+ = "/sys/class/leds/green/delay_off";
+
+char const*const BLUE_DELAY_ON_FILE
+ = "/sys/class/leds/blue/delay_on";
+
+char const*const BLUE_DELAY_OFF_FILE
+ = "/sys/class/leds/blue/delay_off";
+
+#define LED_DELAY_MAX_MS 1500
+
+#endif /* End..(LED_DELAY_FUNC_USAGE) */
+
+
char const*const PERSISTENCE_FILE
= "/sys/class/graphics/fb0/msm_fb_persist_mode";
@@ -214,42 +277,88 @@
blink = 0;
}
+ LIGHT_DBG("red=%02X, green=%02X, blue=%02X, blink=%d\n", red, green, blue, blink );
+
if (blink) {
+ write_int( RED_BLINK_FILE, 0 );
+ write_int( GREEN_BLINK_FILE, 0 );
+ write_int( BLUE_BLINK_FILE, 0 );
+ usleep( 6000 ); /* Delay 6ms for off effective and complete */
+
if (red) {
if (write_int(RED_BLINK_FILE, blink))
write_int(RED_LED_FILE, 0);
}
+ else
+ {
+ write_int( RED_LED_FILE, 0 );
+ }
+
if (green) {
if (write_int(GREEN_BLINK_FILE, blink))
write_int(GREEN_LED_FILE, 0);
}
+ else
+ {
+ write_int( GREEN_LED_FILE, 0 );
+ }
+
if (blue) {
if (write_int(BLUE_BLINK_FILE, blink))
write_int(BLUE_LED_FILE, 0);
}
+ else
+ {
+ write_int( BLUE_LED_FILE, 0 );
+ }
} else {
+ write_int( RED_LED_FILE, 0 );
+ write_int( GREEN_LED_FILE, 0 );
+ write_int( BLUE_LED_FILE, 0 );
+ usleep( 6000 ); /* Delay 6ms for off effective and complete */
+
write_int(RED_LED_FILE, red);
write_int(GREEN_LED_FILE, green);
write_int(BLUE_LED_FILE, blue);
}
+ usleep( 5000 ); /* 5ms */
return 0;
}
+#if defined( LED_FIRST_NOTIFICATION )
+ #undef LED_FIRST_NOTIFICATION
+#endif
+ #define LED_FIRST_NOTIFICATION 1
+
static void
handle_speaker_battery_locked(struct light_device_t* dev)
{
+#if( LED_FIRST_NOTIFICATION )
+ if( is_lit( &g_notification ))
+ {
+ LIGHT_DBG("Notification\n");
+ set_speaker_light_locked( dev, &g_notification );
+ }
+ else
+ {
+ LIGHT_DBG("Battery\n");
+ set_speaker_light_locked( dev, &g_battery );
+ }
+#else /* Default */
if (is_lit(&g_battery)) {
set_speaker_light_locked(dev, &g_battery);
} else {
set_speaker_light_locked(dev, &g_notification);
}
+#endif
}
static int
set_light_battery(struct light_device_t* dev,
struct light_state_t const* state)
{
+ LIGHT_DBG("Enter...\n");
pthread_mutex_lock(&g_lock);
g_battery = *state;
handle_speaker_battery_locked(dev);
@@ -261,6 +370,7 @@
set_light_notifications(struct light_device_t* dev,
struct light_state_t const* state)
{
+ LIGHT_DBG("Enter...\n");
pthread_mutex_lock(&g_lock);
g_notification = *state;
handle_speaker_battery_locked(dev);
@@ -321,6 +431,7 @@
int (*set_light)(struct light_device_t* dev,
struct light_state_t const* state);
+ LIGHT_DBG("Enter...\n");
if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) {
set_light = set_light_backlight;
} else if (0 == strcmp(LIGHT_ID_BATTERY, name))