summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Solano <csolano@gmail.com>2017-08-28 05:47:36 +0000
committerGerrit Code Review <gerrit2@aicp-server-3>2017-08-28 05:47:36 +0000
commita9dd32c991e8dc7180e11768b85cf441503d55a9 (patch)
tree748335a2f4e789414d3c79d3a03aa3ce70b9b72e
parent3e322d859b1f787f651d23aef36cf154c7716d3f (diff)
parent6a076fee24f5dbd2f4e9ea5b97b6c226716fbce2 (diff)
Merge changes I459f6164,Ia558911c into n7.1n7.1
* changes: overlay: cmsdk: enable adjustable notification led brightness liblight: add led brightness control
-rw-r--r--modules/liblight/lights.c28
-rw-r--r--overlay/vendor/cmsdk/cm/res/res/values/config.xml2
2 files changed, 29 insertions, 1 deletions
diff --git a/modules/liblight/lights.c b/modules/liblight/lights.c
index b1a36e9f..06a6bb43 100644
--- a/modules/liblight/lights.c
+++ b/modules/liblight/lights.c
@@ -286,7 +286,35 @@ static int set_light_notifications(struct light_device_t* dev,
struct light_state_t const* state)
{
pthread_mutex_lock(&g_lock);
+
+ unsigned int brightness;
+ unsigned int color;
+ unsigned int rgb[3];
+
g_notification = *state;
+
+ // If a brightness has been applied by the user
+ brightness = (g_notification.color & 0xFF000000) >> 24;
+ if (brightness > 0 && brightness < 0xFF) {
+
+ // Retrieve each of the RGB colors
+ color = g_notification.color & 0x00FFFFFF;
+ rgb[0] = (color >> 16) & 0xFF;
+ rgb[1] = (color >> 8) & 0xFF;
+ rgb[2] = color & 0xFF;
+
+ // Apply the brightness level
+ if (rgb[0] > 0)
+ rgb[0] = (rgb[0] * brightness) / 0xFF;
+ if (rgb[1] > 0)
+ rgb[1] = (rgb[1] * brightness) / 0xFF;
+ if (rgb[2] > 0)
+ rgb[2] = (rgb[2] * brightness) / 0xFF;
+
+ // Update with the new color
+ g_notification.color = (rgb[0] << 16) + (rgb[1] << 8) + rgb[2];
+ }
+
handle_speaker_light_locked(dev);
pthread_mutex_unlock(&g_lock);
diff --git a/overlay/vendor/cmsdk/cm/res/res/values/config.xml b/overlay/vendor/cmsdk/cm/res/res/values/config.xml
index c4875eb1..c15d19b3 100644
--- a/overlay/vendor/cmsdk/cm/res/res/values/config.xml
+++ b/overlay/vendor/cmsdk/cm/res/res/values/config.xml
@@ -40,5 +40,5 @@
For example, a device support pulsating, RGB notification and
battery LEDs would set this config to 11. -->
- <integer name="config_deviceLightCapabilities" translatable="false">11</integer>
+ <integer name="config_deviceLightCapabilities" translatable="false">43</integer>
</resources>