LED: add green/red support for host commands

The host command(ectool) to set led colors will read the brightness
range and then set as requested. If brightness range is 0, then it will just
return INVALID_PARAM.

BUG=chrome-os-partner:35416
TEST=build and run on veyron
       ectool led battery green
       ectool led battery red
       ectool led battery red=1 green=1 #this gives amber
       ectool led battery off
       ectool led power white
       ectool led power off
       ectool led battery auto
       ectool led power auto
BRANCH=veyron

Change-Id: I65a73275741ada5c01e041ae2c11efe3aa2d8c38
(cherry picked from commit ba88b6d6b35959d7ff33cdf075e494406a2f4b5f)
Reviewed-on: https://chromium-review.googlesource.com/345693
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
ZhengShunQian
2015-01-23 16:30:50 +08:00
committed by chrome-bot
parent 2388211bd7
commit 77e23a4fc9

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
/* Copyright 2015 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -88,9 +88,18 @@ static int pwr_led_set_color(enum led_color color)
void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
{
/* Ignoring led_id as both leds support the same colors */
brightness_range[EC_LED_COLOR_BLUE] = 1;
brightness_range[EC_LED_COLOR_YELLOW] = 1;
switch (led_id) {
case EC_LED_ID_BATTERY_LED:
brightness_range[EC_LED_COLOR_RED] = 1;
brightness_range[EC_LED_COLOR_GREEN] = 1;
break;
case EC_LED_ID_POWER_LED:
brightness_range[EC_LED_COLOR_WHITE] = 1;
break;
default:
/* ignore */
break;
}
}
int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)