diff options
author | Vic Yang <victoryang@chromium.org> | 2012-05-25 14:30:37 +0800 |
---|---|---|
committer | Vic Yang <victoryang@chromium.org> | 2012-05-26 20:29:54 +0800 |
commit | b85a7ce9d686799e88bf65fa95ed49c6d561d621 (patch) | |
tree | 07c839b63d24bc123ad6bf20b6c7031f5990055e | |
parent | 7ecd1d6d3c23b6acb13f90062d062647ddb4fed3 (diff) | |
download | chrome-ec-b85a7ce9d686799e88bf65fa95ed49c6d561d621.tar.gz |
Make ectool correctly report when keyboard backlight is off
When keyboard backlight is disabled, make 'ectool pwmgetkblight' reports
'disabled'.
BUG=chrome-os-partner:9966
TEST='ectool pwmgetkblight' shows 'Keyboard backlight disabled' when
lid closed.
Change-Id: Ica690159e30431ccb530275fcc2311fb8f54a9aa
-rw-r--r-- | chip/lm4/pwm.c | 6 | ||||
-rw-r--r-- | common/pwm_commands.c | 1 | ||||
-rw-r--r-- | include/ec_commands.h | 1 | ||||
-rw-r--r-- | include/pwm.h | 3 | ||||
-rw-r--r-- | util/ectool.c | 5 |
5 files changed, 15 insertions, 1 deletions
diff --git a/chip/lm4/pwm.c b/chip/lm4/pwm.c index 79c47e09fc..cf4f776f22 100644 --- a/chip/lm4/pwm.c +++ b/chip/lm4/pwm.c @@ -90,6 +90,12 @@ int pwm_enable_keyboard_backlight(int enable) } +int pwm_get_keyboard_backlight_enabled(void) +{ + return (LM4_FAN_FANCTL & (1 << FAN_CH_KBLIGHT)) ? 1 : 0; +} + + int pwm_get_keyboard_backlight(void) { return ((LM4_FAN_FANCMD(FAN_CH_KBLIGHT) >> 16) * 100 + diff --git a/common/pwm_commands.c b/common/pwm_commands.c index 3a35ff8637..523a803ce0 100644 --- a/common/pwm_commands.c +++ b/common/pwm_commands.c @@ -43,6 +43,7 @@ int pwm_command_get_keyboard_backlight(uint8_t *data, int *resp_size) (struct ec_response_pwm_get_keyboard_backlight *)data; r->percent = pwm_get_keyboard_backlight(); + r->enabled = pwm_get_keyboard_backlight_enabled(); *resp_size = sizeof(struct ec_response_pwm_get_keyboard_backlight); return EC_RES_SUCCESS; } diff --git a/include/ec_commands.h b/include/ec_commands.h index 58490eb108..f76cadb7f3 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -370,6 +370,7 @@ struct ec_params_pwm_set_fan_target_rpm { #define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22 struct ec_response_pwm_get_keyboard_backlight { uint8_t percent; + uint8_t enabled; } __attribute__ ((packed)); /* Set keyboard backlight */ diff --git a/include/pwm.h b/include/pwm.h index edea50e954..356b080532 100644 --- a/include/pwm.h +++ b/include/pwm.h @@ -26,6 +26,9 @@ int pwm_set_fan_target_rpm(int rpm); /* Enable/disable the keyboard backlight. */ int pwm_enable_keyboard_backlight(int enable); +/* Get the keyboard backlight enable/disable status (1=enabled, 0=disabled). */ +int pwm_get_keyboard_backlight_enabled(void); + /* Get the keyboard backlight percentage (0=off, 100=max). */ int pwm_get_keyboard_backlight(void); diff --git a/util/ectool.c b/util/ectool.c index a129791ca0..4c9ff31bb5 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -749,7 +749,10 @@ int cmd_pwm_get_keyboard_backlight(int argc, char *argv[]) if (rv) return rv; - printf("Current keyboard backlight percent: %d\n", r.percent); + if (r.enabled == 1) + printf("Current keyboard backlight percent: %d\n", r.percent); + else + printf("Keyboard backlight disabled.\n"); return 0; } |