diff options
author | Vic Yang <victoryang@chromium.org> | 2014-10-01 10:33:29 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-08 02:50:54 +0000 |
commit | 91cfdd0dac2c1a89f3c8fc2aa8af6ce153589026 (patch) | |
tree | b5a1becfe3efd893bf48635ccf4c317c71f55baa | |
parent | a3ddf04ca9904e73ae6b7bec0218f5861b3f2a74 (diff) | |
download | chrome-ec-91cfdd0dac2c1a89f3c8fc2aa8af6ce153589026.tar.gz |
Remove PULSE and TEST sequences from lightbar module
PULSE and TEST sequences are not used anywhere. Remove them to save
flash space. Also, fix msleep(MSEC) calls in the unit test; it's
essentially usleep(SECOND) written in an incorrect way.
BUG=chrome-os-partner:32203
TEST=make buildall
BRANCH=None
Change-Id: I61ba897df632538eb89364a4c913d5fee87f3864
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220711
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r-- | common/lb_common.c | 26 | ||||
-rw-r--r-- | common/lightbar.c | 70 | ||||
-rw-r--r-- | extra/lightbar/windows.c | 1 | ||||
-rw-r--r-- | include/lb_common.h | 2 | ||||
-rw-r--r-- | include/lightbar_msg_list.h | 8 | ||||
-rw-r--r-- | test/lightbar.c | 104 |
6 files changed, 50 insertions, 161 deletions
diff --git a/common/lb_common.c b/common/lb_common.c index 8803608328..41617f1dff 100644 --- a/common/lb_common.c +++ b/common/lb_common.c @@ -223,32 +223,6 @@ void lb_on(void) controller_write(1, 0x01, 0x20); } -/* - * This sets up the auto-cycling features of the controllers to make a - * semi-random pattern of slowly fading colors. This is interesting only - * because it doesn't require any effort from the EC. -*/ -void lb_start_builtin_cycle(void) -{ - int r = scale(255, MAX_RED); - int g = scale(255, MAX_BLUE); - int b = scale(255, MAX_GREEN); - struct initdata_s pulse_vals[] = { - {0x11, 0xce}, - {0x12, 0x67}, - {0x13, 0xef}, - {0x15, b}, - {0x16, r}, - {0x17, g}, - {0x18, b}, - {0x19, r}, - {0x1a, g}, - }; - - set_from_array(pulse_vals, ARRAY_SIZE(pulse_vals)); - controller_write(1, 0x13, 0xcd); /* this one's different */ -} - static const uint8_t dump_reglist[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0f, diff --git a/common/lightbar.c b/common/lightbar.c index fb1adb41a3..5f05d6799e 100644 --- a/common/lightbar.c +++ b/common/lightbar.c @@ -639,75 +639,6 @@ static uint32_t sequence_S5(void) return 0; } -/* Used by factory. */ -static uint32_t sequence_TEST_inner(void) -{ - int i, k, r, g, b; - int kmax = 254; - int kstep = 8; - - static const struct rgb_s testcolors[] = { - {0xff, 0x00, 0x00}, - {0xff, 0xff, 0x00}, - {0x00, 0xff, 0x00}, - {0x00, 0x00, 0xff}, - {0x00, 0xff, 0xff}, - {0xff, 0x00, 0xff}, - {0xff, 0xff, 0xff}, - }; - - lb_init(); - lb_on(); - for (i = 0; i < ARRAY_SIZE(testcolors); i++) { - for (k = 0; k <= kmax; k += kstep) { - r = testcolors[i].r ? k : 0; - g = testcolors[i].g ? k : 0; - b = testcolors[i].b ? k : 0; - lb_set_rgb(NUM_LEDS, r, g, b); - WAIT_OR_RET(10000); - } - for (k = kmax; k >= 0; k -= kstep) { - r = testcolors[i].r ? k : 0; - g = testcolors[i].g ? k : 0; - b = testcolors[i].b ? k : 0; - lb_set_rgb(NUM_LEDS, r, g, b); - WAIT_OR_RET(10000); - } - } - - lb_set_rgb(NUM_LEDS, 0, 0, 0); - return 0; -} - -static uint32_t sequence_TEST(void) -{ - int tmp; - uint32_t r; - - /* Force brightness to max, then restore it */ - tmp = lb_get_brightness(); - lb_set_brightness(255); - r = sequence_TEST_inner(); - lb_set_brightness(tmp); - return r; -} - -static uint32_t sequence_PULSE(void) -{ - uint32_t msg; - - lb_init(); - lb_on(); - - lb_start_builtin_cycle(); - - /* Not using WAIT_OR_RET() here, because we want to clean up when we're - * done. The only way out is to get a message. */ - msg = task_wait_event(-1); - lb_init(); - return TASK_EVENT_CUSTOM(msg); -} - /* The AP is going to poke at the lightbar directly, so we don't want the EC * messing with it. We'll just sit here and ignore all other messages until * we're told to continue (or until we think the AP is shutting down). @@ -1351,7 +1282,6 @@ void lightbar_task(void) case LIGHTBAR_S3S5: st.cur_seq = LIGHTBAR_S5; break; - case LIGHTBAR_TEST: case LIGHTBAR_STOP: case LIGHTBAR_RUN: case LIGHTBAR_ERROR: diff --git a/extra/lightbar/windows.c b/extra/lightbar/windows.c index 20b3a5780c..e5dd18551b 100644 --- a/extra/lightbar/windows.c +++ b/extra/lightbar/windows.c @@ -233,7 +233,6 @@ void lb_on(void) fake_power = 1; update_window(); }; -void lb_start_builtin_cycle(void) { }; void lb_hc_cmd_dump(struct ec_response_lightbar *out) { printf("lightbar is %s\n", fake_power ? "on" : "off"); diff --git a/include/lb_common.h b/include/lb_common.h index 49ab193254..b68540176b 100644 --- a/include/lb_common.h +++ b/include/lb_common.h @@ -28,8 +28,6 @@ void lb_init(void); void lb_off(void); /* Enable the LED current. */ void lb_on(void); -/* Instruct the IC to run a built-in sequence of color changes. */ -void lb_start_builtin_cycle(void); /* Fill in the response fields for the LIGHTBAR_CMD_DUMP command. */ void lb_hc_cmd_dump(struct ec_response_lightbar *out); /* Write the IC controller register given by the LIGHTBAR_CMD_REG command. */ diff --git a/include/lightbar_msg_list.h b/include/lightbar_msg_list.h index 77b8c60ad2..bb53dacb58 100644 --- a/include/lightbar_msg_list.h +++ b/include/lightbar_msg_list.h @@ -17,8 +17,6 @@ LBMSG(S3S5), /* 7 */ \ LBMSG(STOP), /* 8 */ \ LBMSG(RUN), /* 9 */ \ - LBMSG(PULSE), /* A */ \ - LBMSG(TEST), /* B */ \ - LBMSG(KONAMI), /* C */ \ - LBMSG(TAP), /* D */ \ - LBMSG(PROGRAM), /* E */ + LBMSG(KONAMI), /* A */ \ + LBMSG(TAP), /* B */ \ + LBMSG(PROGRAM), /* C */ diff --git a/test/lightbar.c b/test/lightbar.c index 32473c9ccf..3aae1e71f3 100644 --- a/test/lightbar.c +++ b/test/lightbar.c @@ -56,69 +56,69 @@ static int test_double_oneshots(void) { /* Start in S0 */ TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S0); /* Invoke the oneshot */ - TEST_ASSERT(set_seq(LIGHTBAR_TEST) == EC_RES_SUCCESS); - msleep(MSEC); - TEST_ASSERT(get_seq() == LIGHTBAR_TEST); + TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); + usleep(SECOND); + TEST_ASSERT(get_seq() == LIGHTBAR_TAP); /* Switch to a different oneshot while that one's running */ TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); /* Afterwards, it should go back to the original normal state */ - msleep(30 * MSEC); + usleep(30 * SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S0); /* Same test, but with a bunch more oneshots. */ TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S0); - TEST_ASSERT(set_seq(LIGHTBAR_TEST) == EC_RES_SUCCESS); - msleep(MSEC); - TEST_ASSERT(get_seq() == LIGHTBAR_TEST); + TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); + usleep(SECOND); + TEST_ASSERT(get_seq() == LIGHTBAR_TAP); TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_TAP); - TEST_ASSERT(set_seq(LIGHTBAR_PULSE) == EC_RES_SUCCESS); - msleep(MSEC); - TEST_ASSERT(get_seq() == LIGHTBAR_PULSE); TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); + TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); + usleep(SECOND); + TEST_ASSERT(get_seq() == LIGHTBAR_TAP); /* It should still go back to the original normal state */ - msleep(30 * MSEC); + usleep(30 * SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S0); /* But if the interruption is a normal state, that should stick. */ TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S0); - TEST_ASSERT(set_seq(LIGHTBAR_TEST) == EC_RES_SUCCESS); - msleep(MSEC); - TEST_ASSERT(get_seq() == LIGHTBAR_TEST); + TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); + usleep(SECOND); + TEST_ASSERT(get_seq() == LIGHTBAR_TAP); TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); /* Here's a normal sequence */ TEST_ASSERT(set_seq(LIGHTBAR_S3) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S3); /* And another one-shot */ TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_TAP); - TEST_ASSERT(set_seq(LIGHTBAR_PULSE) == EC_RES_SUCCESS); - msleep(MSEC); - TEST_ASSERT(get_seq() == LIGHTBAR_PULSE); TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); + TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); + usleep(SECOND); + TEST_ASSERT(get_seq() == LIGHTBAR_TAP); /* It should go back to the new normal sequence */ - msleep(30 * MSEC); + usleep(30 * SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S3); return EC_SUCCESS; @@ -128,8 +128,6 @@ static int test_oneshots_norm_msg(void) { /* Revert to the next state when interrupted with a normal message. */ enum lightbar_sequence seqs[] = { - LIGHTBAR_PULSE, - LIGHTBAR_TEST, LIGHTBAR_KONAMI, LIGHTBAR_TAP, }; @@ -138,17 +136,17 @@ static int test_oneshots_norm_msg(void) for (i = 0; i < ARRAY_SIZE(seqs); i++) { /* Start in S0 */ TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); /* Invoke the oneshot */ TEST_ASSERT(set_seq(seqs[i]) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); /* Interrupt with S0S3 */ TEST_ASSERT(set_seq(LIGHTBAR_S0S3) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); /* It should be back right away */ TEST_ASSERT(get_seq() == LIGHTBAR_S0S3); /* And transition on to the correct value */ - msleep(30 * MSEC); + usleep(30 * SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S3); } @@ -162,14 +160,14 @@ static int test_stop_timeout(void) for (i = 0; i < LIGHTBAR_NUM_SEQUENCES; i++) { /* Start in S0 */ TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); /* Tell it to stop */ TEST_ASSERT(set_seq(LIGHTBAR_STOP) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_STOP); /* Try to interrupt it */ TEST_ASSERT(set_seq(i) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); /* What happened? */ if (i == LIGHTBAR_RUN || i == LIGHTBAR_S0S3 || i == LIGHTBAR_S3 || @@ -182,7 +180,7 @@ static int test_stop_timeout(void) /* Let it RUN again for the next iteration */ TEST_ASSERT(set_seq(LIGHTBAR_RUN) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); } TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); @@ -194,7 +192,6 @@ static int test_oneshots_timeout(void) /* These should revert to the previous state after running */ enum lightbar_sequence seqs[] = { LIGHTBAR_RUN, - LIGHTBAR_TEST, LIGHTBAR_KONAMI, LIGHTBAR_TAP, }; @@ -202,15 +199,15 @@ static int test_oneshots_timeout(void) for (i = 0; i < ARRAY_SIZE(seqs); i++) { TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(set_seq(seqs[i]) == EC_RES_SUCCESS); /* Assume the oneshot sequence takes at least a second (except * for LIGHTBAR_RUN, which returns immediately) */ if (seqs[i] != LIGHTBAR_RUN) { - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == seqs[i]); } - msleep(30 * MSEC); + usleep(30 * SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S0); } @@ -221,22 +218,22 @@ static int test_transition_states(void) { /* S5S3 */ TEST_ASSERT(set_seq(LIGHTBAR_S5S3) == EC_RES_SUCCESS); - msleep(10 * MSEC); + usleep(10 * SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S3); /* S3S0 */ TEST_ASSERT(set_seq(LIGHTBAR_S3S0) == EC_RES_SUCCESS); - msleep(10 * MSEC); + usleep(10 * SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S0); /* S0S3 */ TEST_ASSERT(set_seq(LIGHTBAR_S0S3) == EC_RES_SUCCESS); - msleep(10 * MSEC); + usleep(10 * SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S3); /* S3S5 */ TEST_ASSERT(set_seq(LIGHTBAR_S3S5) == EC_RES_SUCCESS); - msleep(10 * MSEC); + usleep(10 * SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S5); return EC_SUCCESS; @@ -254,31 +251,24 @@ static int test_stable_states(void) /* It should stay there */ for (i = 0; i < 30; i++) { - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S5); } /* S3 is sticky, too */ TEST_ASSERT(set_seq(LIGHTBAR_S3) == EC_RES_SUCCESS); for (i = 0; i < 30; i++) { - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S3); } /* And S0 */ TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); for (i = 0; i < 30; i++) { - msleep(MSEC); + usleep(SECOND); TEST_ASSERT(get_seq() == LIGHTBAR_S0); } - /* PULSE is stable too, but nobody should care. Test it anyway. */ - TEST_ASSERT(set_seq(LIGHTBAR_PULSE) == EC_RES_SUCCESS); - for (i = 0; i < 30; i++) { - msleep(MSEC); - TEST_ASSERT(get_seq() == LIGHTBAR_PULSE); - } - return EC_SUCCESS; } |