summaryrefslogtreecommitdiff
path: root/common/lightbar.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2015-03-24 17:10:30 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-31 23:00:33 +0000
commit3282296f2ba2471b753868f004811ef7046e44c2 (patch)
tree3ceccabd9e539d9774c3480940ca50f29d499875 /common/lightbar.c
parenta4c4a2e7abf630612fa62497fdbd982cf1094a24 (diff)
downloadchrome-ec-3282296f2ba2471b753868f004811ef7046e44c2.tar.gz
ec: Created lightbar params v2
The 'lightbar params' v1 command has a parameter list that exceeds 120 bytes, which will not work over i2c. Therefore, I created a params v2 command which breaks up the existing parameters into logical groups which are less than 120 bytes. TEST=Tested new lightbar params2 command and ran get/sets on all groups for samus. Repeated test on ryu as well. BUG=chromium:467716 BRANCH=none Change-Id: If0fa92e9a2f373b20257f8ce7eb66b7836d9ac60 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/263106 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/lightbar.c')
-rw-r--r--common/lightbar.c101
1 files changed, 100 insertions, 1 deletions
diff --git a/common/lightbar.c b/common/lightbar.c
index ed25b55cb2..879da25531 100644
--- a/common/lightbar.c
+++ b/common/lightbar.c
@@ -65,9 +65,31 @@ static struct p_state {
uint8_t _pad0; /* next item is __packed */
/* Tweakable parameters. */
- struct lightbar_params_v1 p;
+ union {
+ struct lightbar_params_v1 p;
+ struct {
+ struct lightbar_params_v2_timing timing;
+ struct lightbar_params_v2_tap tap;
+ struct lightbar_params_v2_oscillation osc;
+ struct lightbar_params_v2_brightness bright;
+ struct lightbar_params_v2_thresholds thlds;
+ struct lightbar_params_v2_colors colors;
+ } p_v2;
+ };
} st;
+/* Each of the parameters must be less than 120 bytes
+ * (crbug.com/467716)
+ */
+#define MAX_PARAM_SIZE 120
+BUILD_ASSERT(sizeof(struct lightbar_params_v2_timing) <= MAX_PARAM_SIZE);
+BUILD_ASSERT(sizeof(struct lightbar_params_v2_tap) <= MAX_PARAM_SIZE);
+BUILD_ASSERT(sizeof(struct lightbar_params_v2_oscillation) <= MAX_PARAM_SIZE);
+BUILD_ASSERT(sizeof(struct lightbar_params_v2_brightness) <= MAX_PARAM_SIZE);
+BUILD_ASSERT(sizeof(struct lightbar_params_v2_thresholds) <= MAX_PARAM_SIZE);
+BUILD_ASSERT(sizeof(struct lightbar_params_v2_colors) <= MAX_PARAM_SIZE);
+#undef MAX_PARAM_SIZE
+
static const struct lightbar_params_v1 default_params = {
.google_ramp_up = 2500,
.google_ramp_down = 10000,
@@ -1720,6 +1742,83 @@ static int lpc_cmd_lightbar(struct host_cmd_handler_args *args)
CPRINTS("LB_resume");
lightbar_sequence(LIGHTBAR_S3S0);
break;
+ case LIGHTBAR_CMD_GET_PARAMS_V2_TIMING:
+ CPRINTS("LB_get_params_v2_timing");
+ memcpy(&out->get_params_v2_timing,
+ &st.p_v2.timing,
+ sizeof(st.p_v2.timing));
+ args->response_size = sizeof(out->get_params_v2_timing);
+ break;
+ case LIGHTBAR_CMD_SET_PARAMS_V2_TIMING:
+ CPRINTS("LB_set_params_v2_timing");
+ memcpy(&st.p_v2.timing,
+ &in->set_v2par_timing,
+ sizeof(struct lightbar_params_v2_timing));
+ break;
+ case LIGHTBAR_CMD_GET_PARAMS_V2_TAP:
+ CPRINTS("LB_get_params_v2_tap");
+ memcpy(&out->get_params_v2_tap,
+ &st.p_v2.tap,
+ sizeof(struct lightbar_params_v2_tap));
+ args->response_size = sizeof(out->get_params_v2_tap);
+ break;
+ case LIGHTBAR_CMD_SET_PARAMS_V2_TAP:
+ CPRINTS("LB_set_params_v2_tap");
+ memcpy(&st.p_v2.tap,
+ &in->set_v2par_tap,
+ sizeof(struct lightbar_params_v2_tap));
+ break;
+ case LIGHTBAR_CMD_GET_PARAMS_V2_OSCILLATION:
+ CPRINTS("LB_get_params_v2_oscillation");
+ memcpy(&out->get_params_v2_osc, &st.p_v2.osc,
+ sizeof(struct lightbar_params_v2_oscillation));
+ args->response_size = sizeof(out->get_params_v2_osc);
+ break;
+ case LIGHTBAR_CMD_SET_PARAMS_V2_OSCILLATION:
+ CPRINTS("LB_set_params_v2_oscillation");
+ memcpy(&st.p_v2.osc,
+ &in->set_v2par_osc,
+ sizeof(struct lightbar_params_v2_oscillation));
+ break;
+ case LIGHTBAR_CMD_GET_PARAMS_V2_BRIGHTNESS:
+ CPRINTS("LB_get_params_v2_brightness");
+ memcpy(&out->get_params_v2_bright,
+ &st.p_v2.bright,
+ sizeof(struct lightbar_params_v2_brightness));
+ args->response_size = sizeof(out->get_params_v2_bright);
+ break;
+ case LIGHTBAR_CMD_SET_PARAMS_V2_BRIGHTNESS:
+ CPRINTS("LB_set_params_v2_brightness");
+ memcpy(&st.p_v2.bright,
+ &in->set_v2par_bright,
+ sizeof(struct lightbar_params_v2_brightness));
+ break;
+ case LIGHTBAR_CMD_GET_PARAMS_V2_THRESHOLDS:
+ CPRINTS("LB_get_params_v2_thlds");
+ memcpy(&out->get_params_v2_thlds,
+ &st.p_v2.thlds,
+ sizeof(struct lightbar_params_v2_thresholds));
+ args->response_size = sizeof(out->get_params_v2_thlds);
+ break;
+ case LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS:
+ CPRINTS("LB_set_params_v2_thlds");
+ memcpy(&st.p_v2.thlds,
+ &in->set_v2par_thlds,
+ sizeof(struct lightbar_params_v2_thresholds));
+ break;
+ case LIGHTBAR_CMD_GET_PARAMS_V2_COLORS:
+ CPRINTS("LB_get_params_v2_colors");
+ memcpy(&out->get_params_v2_colors,
+ &st.p_v2.colors,
+ sizeof(struct lightbar_params_v2_colors));
+ args->response_size = sizeof(out->get_params_v2_colors);
+ break;
+ case LIGHTBAR_CMD_SET_PARAMS_V2_COLORS:
+ CPRINTS("LB_set_params_v2_colors");
+ memcpy(&st.p_v2.colors,
+ &in->set_v2par_colors,
+ sizeof(struct lightbar_params_v2_colors));
+ break;
default:
CPRINTS("LB bad cmd 0x%x", in->cmd);
return EC_RES_INVALID_PARAM;