summaryrefslogtreecommitdiff
path: root/util/lbplay.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-01-08 16:53:48 -0800
committerChromeBot <chrome-bot@google.com>2013-01-11 16:14:59 -0800
commit024f292edf44a9223d6101edc31571df067a8dce (patch)
tree0b6a777967b1ca7a3602a6e04a5fb350bb9fed5a /util/lbplay.c
parent2de1227f4437d45d310759f5e4407d7cc9db74f5 (diff)
downloadchrome-ec-024f292edf44a9223d6101edc31571df067a8dce.tar.gz
Add AP userspace scripts to tweak lightbar colorsstabilize-link-2913.278
We have yet another tweak for the lightbar, but we don't want to update the EC. This CL adds an init script that runs on the AP at every boot and pokes the EC to modify the lightbar settings. We have to run it at every boot because the EC will hibernate after the AP has been off (not suspended) for an hour on battery power and will lose its settings. There's a corresponding CL for the ec-utils ebuild that installs the userspace scripts into the rootfs. NOTE that in order to cherry-pick this into R23 from ToT, we have to update ectool as well, because the original R23 ectool doesn't implement the "lightbar params" command. However, the EC image that ectool talks to is built from a *different* branch that already has the ectool update, so this change DOESN'T backport any of the EC firmware changes that would otherwise be required. Instead, we just hack a little bit to make the EC firmware compile. BUG=chrome-os-partner:16827 BRANCH=link TEST=manual Build the image for Link, install, reboot. Run "ectool lightbar params". The output should match what's in /usr/share/ec/lightbar_params.txt Original-Change-Id: If50ac2ef2432f7d60cdaf4c222b68dbdee80b2ec Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/39979 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Richard Barnette <jrbarnette@chromium.org> (cherry picked from commit 3eb6f58d3e18647797ad4e3f16203c419ed4c791) Change-Id: Ied2304da58d6d27b4f186e621bb187ba9a574e6c Reviewed-on: https://gerrit.chromium.org/gerrit/41167 Commit-Queue: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'util/lbplay.c')
-rw-r--r--util/lbplay.c113
1 files changed, 58 insertions, 55 deletions
diff --git a/util/lbplay.c b/util/lbplay.c
index 9acabaddfb..907374e9cc 100644
--- a/util/lbplay.c
+++ b/util/lbplay.c
@@ -18,40 +18,38 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#define LB_SIZES(SUBCMD) { \
+ sizeof(((struct ec_params_lightbar *)0)->SUBCMD) \
+ + sizeof(((struct ec_params_lightbar *)0)->cmd), \
+ sizeof(((struct ec_response_lightbar *)0)->SUBCMD) }
static const struct {
uint8_t insize;
uint8_t outsize;
} lb_command_paramcount[] = {
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.dump),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.dump) },
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.off),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.off) },
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.on),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.on) },
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.init),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.init) },
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.brightness),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.brightness) },
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.seq),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.seq) },
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.reg),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.reg) },
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.rgb),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.rgb) },
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.get_seq),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.get_seq) },
- { sizeof(((struct ec_params_lightbar_cmd *)0)->in.demo),
- sizeof(((struct ec_params_lightbar_cmd *)0)->out.demo) },
+ LB_SIZES(dump),
+ LB_SIZES(off),
+ LB_SIZES(on),
+ LB_SIZES(init),
+ LB_SIZES(brightness),
+ LB_SIZES(seq),
+ LB_SIZES(reg),
+ LB_SIZES(rgb),
+ LB_SIZES(get_seq),
+ LB_SIZES(demo),
+ LB_SIZES(get_params),
+ LB_SIZES(set_params)
};
+#undef LB_SIZES
static void lb_cmd_noargs(enum lightbar_command cmd)
{
- struct ec_params_lightbar_cmd param;
- param.in.cmd = cmd;
+ struct ec_params_lightbar param;
+ struct ec_response_lightbar resp;
+ param.cmd = cmd;
ec_command(EC_CMD_LIGHTBAR_CMD, 0,
- &param, lb_command_paramcount[param.in.cmd].insize,
- &param, lb_command_paramcount[param.in.cmd].outsize);
+ &param, lb_command_paramcount[param.cmd].insize,
+ &resp, lb_command_paramcount[param.cmd].outsize);
}
inline void lightbar_off(void)
@@ -71,68 +69,73 @@ inline void lightbar_init_vals(void)
void lightbar_brightness(int newval)
{
- struct ec_params_lightbar_cmd param;
- param.in.cmd = LIGHTBAR_CMD_BRIGHTNESS;
- param.in.brightness.num = newval;
+ struct ec_params_lightbar param;
+ struct ec_response_lightbar resp;
+ param.cmd = LIGHTBAR_CMD_BRIGHTNESS;
+ param.brightness.num = newval;
ec_command(EC_CMD_LIGHTBAR_CMD, 0,
- &param, lb_command_paramcount[param.in.cmd].insize,
- &param, lb_command_paramcount[param.in.cmd].outsize);
+ &param, lb_command_paramcount[param.cmd].insize,
+ &resp, lb_command_paramcount[param.cmd].outsize);
}
void lightbar_sequence(enum lightbar_sequence num)
{
- struct ec_params_lightbar_cmd param;
- param.in.cmd = LIGHTBAR_CMD_SEQ;
- param.in.seq.num = num;
+ struct ec_params_lightbar param;
+ struct ec_response_lightbar resp;
+ param.cmd = LIGHTBAR_CMD_SEQ;
+ param.seq.num = num;
ec_command(EC_CMD_LIGHTBAR_CMD, 0,
- &param, lb_command_paramcount[param.in.cmd].insize,
- &param, lb_command_paramcount[param.in.cmd].outsize);
+ &param, lb_command_paramcount[param.cmd].insize,
+ &resp, lb_command_paramcount[param.cmd].outsize);
}
void lightbar_reg(uint8_t ctrl, uint8_t reg, uint8_t val)
{
- struct ec_params_lightbar_cmd param;
- param.in.cmd = LIGHTBAR_CMD_REG;
- param.in.reg.ctrl = ctrl;
- param.in.reg.reg = reg;
- param.in.reg.value = val;
+ struct ec_params_lightbar param;
+ struct ec_response_lightbar resp;
+ param.cmd = LIGHTBAR_CMD_REG;
+ param.reg.ctrl = ctrl;
+ param.reg.reg = reg;
+ param.reg.value = val;
ec_command(EC_CMD_LIGHTBAR_CMD, 0,
- &param, lb_command_paramcount[param.in.cmd].insize,
- &param, lb_command_paramcount[param.in.cmd].outsize);
+ &param, lb_command_paramcount[param.cmd].insize,
+ &resp, lb_command_paramcount[param.cmd].outsize);
}
void lightbar_rgb(int led, int red, int green, int blue)
{
- struct ec_params_lightbar_cmd param;
- param.in.cmd = LIGHTBAR_CMD_RGB;
- param.in.rgb.led = led;
- param.in.rgb.red = red;
- param.in.rgb.green = green;
- param.in.rgb.blue = blue;
+ struct ec_params_lightbar param;
+ struct ec_response_lightbar resp;
+ param.cmd = LIGHTBAR_CMD_RGB;
+ param.rgb.led = led;
+ param.rgb.red = red;
+ param.rgb.green = green;
+ param.rgb.blue = blue;
ec_command(EC_CMD_LIGHTBAR_CMD, 0,
- &param, lb_command_paramcount[param.in.cmd].insize,
- &param, lb_command_paramcount[param.in.cmd].outsize);
+ &param, lb_command_paramcount[param.cmd].insize,
+ &resp, lb_command_paramcount[param.cmd].outsize);
}
void wait_for_ec_to_stop(void)
{
int r;
- struct ec_params_lightbar_cmd param;
+ struct ec_params_lightbar param;
+ struct ec_response_lightbar resp;
int count = 0;
do {
usleep(100000);
- param.in.cmd = LIGHTBAR_CMD_GET_SEQ;
+ param.cmd = LIGHTBAR_CMD_GET_SEQ;
r = ec_command(EC_CMD_LIGHTBAR_CMD, 0,
&param,
- lb_command_paramcount[param.in.cmd].insize,
- &param,
- lb_command_paramcount[param.in.cmd].outsize);
+ lb_command_paramcount[param.cmd].insize,
+ &resp,
+ lb_command_paramcount[param.cmd].outsize);
if (count++ > 10) {
fprintf(stderr, "EC isn't responding\n");
exit(1);
}
- } while (r < 0 && param.out.get_seq.num != LIGHTBAR_STOP);
+ } while (r < 0 && resp.get_seq.num != LIGHTBAR_STOP);
}
int main(int argc, char **argv)