summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-08-29 12:46:37 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-08-30 16:47:14 +0000
commit32045efb23efdb8c68689ff871a24b9c19c75546 (patch)
tree80f8c2f9250fc14cf5b01e48b3489add3b52b9fa
parentcfd007c833a676ca2e5b82503f5871ec2531f322 (diff)
downloadchrome-ec-stabilize-4636.B.tar.gz
Add LIGHTBAR_CMD_VERSION command to detect lightbar features.stabilize-4636.B
Most systems don't have a lightbar. Those that do need a way to detect that one exists. That's easily done by just sending a EC_CMD_LIGHTBAR_CMD command to the EC and checking the result. If the response is EC_RES_INVALID_COMMAND, there isn't a lightbar. But what .cmd value should we use in struct ec_params_lightbar? Future lightbar implementations (if any), could remove existing functions or add new ones, so there isn't a safe choice. This change adds a LIGHTBAR_CMD_VERSION operation to determine if any new implementation exists. Future systems should return some useful information in response to this command. Existing systems will return EC_RES_INVALID_PARAM, which is enough to distinguish them. BUG=chromium:239205 BRANCH=none TEST=manual make BOARD=link make BOARD=link runtests There are no user-visible changes in functionality to anything. Change-Id: Ibe37f74a4dcbf68dd6bfd1963530aec907e67534 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167549 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/lightbar.c13
-rw-r--r--include/ec_commands.h8
-rw-r--r--util/ectool.c10
-rw-r--r--util/lbplay.c3
4 files changed, 32 insertions, 2 deletions
diff --git a/common/lightbar.c b/common/lightbar.c
index 7471e523d7..e90cc06497 100644
--- a/common/lightbar.c
+++ b/common/lightbar.c
@@ -21,6 +21,13 @@
#include "timer.h"
#include "util.h"
+
+/* The Link lightbar had no specific version. Any new ones should, especially
+ * if they are different in any way. If anything changes, update these.
+ */
+#define LIGHTBAR_IMPLEMENTATION_VERSION 1
+#define LIGHTBAR_IMPLEMENTATION_FLAGS 0x00000000
+
/* Console output macros */
#define CPUTS(outstr) cputs(CC_LIGHTBAR, outstr)
#define CPRINTF(format, args...) cprintf(CC_LIGHTBAR, format, ## args)
@@ -1144,6 +1151,12 @@ static int lpc_cmd_lightbar(struct host_cmd_handler_args *args)
CPRINTF("[%T LB_set_params]\n");
memcpy(&st.p, &in->set_params, sizeof(st.p));
break;
+ case LIGHTBAR_CMD_VERSION:
+ CPRINTF("[%T LB_version]\n");
+ out->version.num = LIGHTBAR_IMPLEMENTATION_VERSION;
+ out->version.flags = LIGHTBAR_IMPLEMENTATION_FLAGS;
+ args->response_size = sizeof(out->version);
+ break;
default:
CPRINTF("[%T LB bad cmd 0x%x]\n", in->cmd);
return EC_RES_INVALID_PARAM;
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 08fb20a996..b3feff7ce1 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -926,7 +926,7 @@ struct ec_params_lightbar {
union {
struct {
/* no args */
- } dump, off, on, init, get_seq, get_params;
+ } dump, off, on, init, get_seq, get_params, version;
struct num {
uint8_t num;
@@ -960,6 +960,11 @@ struct ec_response_lightbar {
struct lightbar_params get_params;
+ struct version {
+ uint32_t num;
+ uint32_t flags;
+ } version;
+
struct {
/* no return params */
} off, on, init, brightness, seq, reg, rgb, demo, set_params;
@@ -980,6 +985,7 @@ enum lightbar_command {
LIGHTBAR_CMD_DEMO = 9,
LIGHTBAR_CMD_GET_PARAMS = 10,
LIGHTBAR_CMD_SET_PARAMS = 11,
+ LIGHTBAR_CMD_VERSION = 12,
LIGHTBAR_NUM_CMDS
};
diff --git a/util/ectool.c b/util/ectool.c
index b25edb88b8..59ebde3e9a 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -1260,6 +1260,7 @@ static const struct {
LB_SIZES(demo),
LB_SIZES(get_params),
LB_SIZES(set_params),
+ LB_SIZES(version),
};
#undef LB_SIZES
@@ -1532,6 +1533,15 @@ static int cmd_lightbar(int argc, char **argv)
return r;
}
+ if (!strcasecmp(argv[1], "version")) {
+ r = lb_do_cmd(LIGHTBAR_CMD_VERSION, &param, &resp);
+ if (!r) {
+ printf("num: %d\n", resp.version.num);
+ printf("flags: 0x%x\n", resp.version.flags);
+ }
+ return r;
+ }
+
if (argc == 3 && !strcasecmp(argv[1], "brightness")) {
char *e;
param.brightness.num = 0xff & strtoul(argv[2], &e, 16);
diff --git a/util/lbplay.c b/util/lbplay.c
index 9cb853aa75..da093a1807 100644
--- a/util/lbplay.c
+++ b/util/lbplay.c
@@ -34,7 +34,8 @@ static const struct {
LB_SIZES(get_seq),
LB_SIZES(demo),
LB_SIZES(get_params),
- LB_SIZES(set_params)
+ LB_SIZES(set_params),
+ LB_SIZES(version)
};
#undef LB_SIZES