summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-05-26 14:38:38 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-05-27 18:08:58 -0700
commitd1beddc463f488e527a90bf5adea92e4e9199a8f (patch)
tree606209a936928e338424abf219f6eddf933304f3 /util
parent8f886b40f4335a43bde5da9096308ae91935c7eb (diff)
downloadchrome-ec-d1beddc463f488e527a90bf5adea92e4e9199a8f.tar.gz
pwm: Modify new PWM host commands to take 16-bit duty cycle
EC_CMD_PWM_SET_DUTY / EC_CMD_PWM_GET_DUTY were recently added and are not yet in use. Future-proof these commands by taking a 16-bit duty cycle parameter and converting it between the [0-100] percent used by internal EC functions. BUG=chromium:615109 BRANCH=None TEST=Manual on chell. `ectool pwmsetduty kb 65535` - Verify KB backlight goes to 100% `ectool pwmgetduty kb` - Prints 65535 `ectool pwmgetduty 0` - Prints 65535 `ectool pwmsetduty 0 0` - Verify KB backlight goes to 0% `ectool pwmgetduty kb` - Prints 0 `ectool pwmgetduty disp` - Error res 3 (unsupported PWM type) `ectool pwmsetduty 1` - Error res 3 (non-existent PWM index) `ectool pwmsetduty kb 6550` + `ectool pwmgetduty kb` - Prints 6553 (round up) `ectool pwmsetduty kb 6560` + `ectool pwmgetduty kb` - Prints 6553 (round down) Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ic6996fc6e1e69359274b2f9a1120ee7002db991c Reviewed-on: https://chromium-review.googlesource.com/347608 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Tested-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Brian Norris <briannorris@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/util/ectool.c b/util/ectool.c
index a1210466f5..364ec2f99f 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -176,13 +176,13 @@ const char help_str[] =
" pwmgetnumfans\n"
" Prints the number of fans present\n"
" pwmgetduty\n"
- " Prints the current duty cycle for given PWM\n"
+ " Prints the current 16 bit duty cycle for given PWM\n"
" pwmsetfanrpm <targetrpm>\n"
" Set target fan RPM\n"
" pwmsetkblight <percent>\n"
" Set keyboard backlight in percent\n"
" pwmsetduty\n"
- " Set duty cycle of given PWM in percent\n"
+ " Set 16 bit duty cycle of given PWM\n"
" readtest <patternoffset> <size>\n"
" Reads a pattern from the EC via LPC\n"
" reboot_ec <RO|RW|cold|hibernate|disable-jump> [at-shutdown]\n"
@@ -1941,7 +1941,7 @@ int cmd_pwm_get_duty(int argc, char *argv[])
if (rv < 0)
return rv;
- printf("Current PWM duty: %d\n", r.percent);
+ printf("Current PWM duty: %d\n", r.duty);
return 0;
}
@@ -1953,7 +1953,7 @@ int cmd_pwm_set_duty(int argc, char *argv[])
int rv;
if (argc != 3) {
- fprintf(stderr, "Usage: %s <pwm_idx> | kb | disp <percent>\n",
+ fprintf(stderr, "Usage: %s <pwm_idx> | kb | disp <duty>\n",
argv[0]);
return -1;
}
@@ -1973,9 +1973,9 @@ int cmd_pwm_set_duty(int argc, char *argv[])
}
}
- p.percent = strtol(argv[2], &e, 0);
+ p.duty = strtol(argv[2], &e, 0);
if (e && *e) {
- fprintf(stderr, "Bad percent.\n");
+ fprintf(stderr, "Bad duty.\n");
return -1;
}