summaryrefslogtreecommitdiff
path: root/extra/lightbar
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /extra/lightbar
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-factory-guybrush-14600.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'extra/lightbar')
-rw-r--r--extra/lightbar/.gitignore1
-rw-r--r--extra/lightbar/Makefile28
-rw-r--r--extra/lightbar/README39
-rw-r--r--extra/lightbar/input.c80
-rw-r--r--extra/lightbar/main.c329
-rw-r--r--extra/lightbar/programs/bad-decode-32.bin1
-rw-r--r--extra/lightbar/programs/bad-decode-8.binbin3 -> 0 bytes
-rw-r--r--extra/lightbar/programs/bad-jump.bin1
-rw-r--r--extra/lightbar/programs/bad-opcode.bin1
-rw-r--r--extra/lightbar/programs/green-pulse.binbin19 -> 0 bytes
-rw-r--r--extra/lightbar/programs/green-pulse.lbs8
-rw-r--r--extra/lightbar/programs/infinite-jump.binbin2 -> 0 bytes
-rw-r--r--extra/lightbar/programs/infinite-jump.lbs1
-rw-r--r--extra/lightbar/programs/konami.binbin144 -> 0 bytes
-rw-r--r--extra/lightbar/programs/konami.lbs89
-rw-r--r--extra/lightbar/programs/rainbow-shift.binbin31 -> 0 bytes
-rw-r--r--extra/lightbar/programs/rainbow-shift.lbs8
-rw-r--r--extra/lightbar/programs/red-green-blink.binbin29 -> 0 bytes
-rw-r--r--extra/lightbar/programs/red-green-blink.lbs14
-rw-r--r--extra/lightbar/programs/s0.binbin58 -> 0 bytes
-rw-r--r--extra/lightbar/programs/s0.lbs22
-rw-r--r--extra/lightbar/programs/s0s3.binbin43 -> 0 bytes
-rw-r--r--extra/lightbar/programs/s0s3.lbs16
-rw-r--r--extra/lightbar/programs/s3.binbin37 -> 0 bytes
-rw-r--r--extra/lightbar/programs/s3.lbs17
-rw-r--r--extra/lightbar/programs/s3s0.binbin34 -> 0 bytes
-rw-r--r--extra/lightbar/programs/s3s0.lbs11
-rw-r--r--extra/lightbar/simulation.h117
-rw-r--r--extra/lightbar/windows.c293
29 files changed, 0 insertions, 1076 deletions
diff --git a/extra/lightbar/.gitignore b/extra/lightbar/.gitignore
deleted file mode 100644
index 964154302a..0000000000
--- a/extra/lightbar/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-lightbar
diff --git a/extra/lightbar/Makefile b/extra/lightbar/Makefile
deleted file mode 100644
index ce84428869..0000000000
--- a/extra/lightbar/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2014 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-PROG= lightbar
-HEADERS= simulation.h
-SRCS= main.c windows.c input.c ../../common/lightbar.c
-
-# comment this out if you don't have libreadline installed
-HAS_GNU_READLINE=1
-
-INCLUDE= -I. -I../../include
-CFLAGS= -g -Wall -Werror -pthread ${INCLUDE} -DLIGHTBAR_SIMULATION
-LDFLAGS = -lX11 -lxcb -lrt
-
-ifneq ($(HAS_GNU_READLINE),)
-CFLAGS += -DHAS_GNU_READLINE
-LDFLAGS += -lreadline
-endif
-
-all: ${PROG}
-
-${PROG} : ${SRCS} ${HEADERS} Makefile
- gcc ${CFLAGS} ${SRCS} ${LDFLAGS} -o ${PROG}
-
-.PHONY: clean
-clean:
- rm -f ${PROG}
diff --git a/extra/lightbar/README b/extra/lightbar/README
deleted file mode 100644
index 1862f922e4..0000000000
--- a/extra/lightbar/README
+++ /dev/null
@@ -1,39 +0,0 @@
-Lightbar simulator
-------------------------------------------------------------------------------
-
-Build with "make lightbar". The executable is "./lightbar".
-
-You may need to install libxcb1-dev or similar.
-
-This provides a simulation environment for the lightbar task, compiling
-common/lightbar.c from the EC source, but faking the rest of the EC.
-
-The EC console is on stdin/stdout, delivering all input to the lightbar's
-console command handler (so it prefixes any input with "lightbar"). The
-lightbar itself is displayed in an X window. You can click in that window to
-emulate changes to the battery level, AC connection, and brightness, all of
-which are normally outside the lightbar task's direct control.
-
-The initial sequence is "S5". Try issuing the command "seq s3s0" to see
-something more familiar.
-
-
-Note: the Pixel lightbar circuitry has three modes of operation:
-
-Unpowered
-
- When the host CPU is off (S5/G3), all power to the lightbar and its
- controller circuitry is lost.
-
-On
-
- When the host CPU is on (S0) or suspended (S3), the lightbar is powered
- again. After every power loss, it will need to be reinitialized by calling
- lb_init() before it can be used.
-
-Standby
-
- The lightbar controller ICs can turn off all the LED outputs to conserve
- power. This is the initial state when power is applied. You can turn the
- LEDs off manually by calling lb_off(). When suspended, the controller will
- respond to commands, but the LEDs aren't lit. Turn them on with lb_on().
diff --git a/extra/lightbar/input.c b/extra/lightbar/input.c
deleted file mode 100644
index e6c5485e39..0000000000
--- a/extra/lightbar/input.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#include "simulation.h"
-
-#ifdef HAS_GNU_READLINE
-#include <readline/readline.h>
-#include <readline/history.h>
-
-char *get_input(const char *prompt)
-{
- static char *line;
-
- if (line) {
- free(line);
- line = 0;
- }
-
- line = readline(prompt);
-
- if (line && *line)
- add_history(line);
-
- return line;
-}
-
-#else /* no readline */
-
-char *get_input(const char *prompt)
-{
- static char mybuf[80];
- char *got;
- printf("%s", prompt);
- got = fgets(mybuf, sizeof(mybuf), stdin);
- return got;
-}
-
-#endif /* HAS_GNU_READLINE */
-
-void *entry_input(void *ptr)
-{
- char *got, buf[80];
- char *str, *word, *saveptr;
- int argc;
- char *argv[40];
- int ret;
-
- do {
- got = get_input("lightbar% ");
- if (got) {
- strcpy(buf, got);
- argc = 0;
- argv[argc++] = "lightbar";
- word = str = buf;
- while (word && argc < ARRAY_SIZE(argv)) {
- word = strtok_r(str, " \t\r\n", &saveptr);
- if (word)
- argv[argc++] = word;
- str = 0;
- }
- argv[argc] = 0;
- ret = fake_consolecmd_lightbar(argc, argv);
- if (ret)
- printf("ERROR %d\n", ret);
- }
-
- } while (got);
-
- exit(0);
-
- return 0;
-}
diff --git a/extra/lightbar/main.c b/extra/lightbar/main.c
deleted file mode 100644
index 5acf3d427a..0000000000
--- a/extra/lightbar/main.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <assert.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <time.h>
-
-#include "simulation.h"
-
-static void *(*thread_fns[])(void *) = {
- entry_windows,
- entry_lightbar,
- entry_input,
-};
-
-int main(int argc, char *argv[])
-{
- int i;
- pthread_t thread[ARRAY_SIZE(thread_fns)];
-
- printf("\nLook at the README file.\n");
- printf("Click in the window.\n");
- printf("Type \"help\" for commands.\n\n");
- fflush(stdout);
-
- init_windows();
-
- for (i = 0; i < ARRAY_SIZE(thread_fns); i++)
- assert(0 == pthread_create(&thread[i], NULL, thread_fns[i], 0));
-
- for (i = 0; i < ARRAY_SIZE(thread_fns); i++)
- pthread_join(thread[i], NULL);
-
- return 0;
-}
-
-void *entry_lightbar(void *ptr)
-{
- lightbar_task();
- return 0;
-}
-
-/****************************************************************************/
-/* Fake functions. We only have to implement enough for lightbar.c */
-
-/* timespec uses nanoseconds */
-#define TS_USEC 1000L
-#define TS_MSEC 1000000L
-#define TS_SEC 1000000000L
-
-static void timespec_incr(struct timespec *v, time_t secs, long nsecs)
-{
- v->tv_sec += secs;
- /* The nanosecond sum won't overflow, but might have a carry. */
- v->tv_nsec += nsecs;
- v->tv_sec += v->tv_nsec / TS_SEC;
- v->tv_nsec %= TS_SEC;
-}
-
-
-static pthread_mutex_t task_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t task_cond = PTHREAD_COND_INITIALIZER;
-static uint32_t task_event;
-
-uint32_t task_wait_event(int timeout_us)
-{
- struct timespec t;
- uint32_t event;
-
- pthread_mutex_lock(&task_mutex);
-
- if (timeout_us > 0) {
- clock_gettime(CLOCK_REALTIME, &t);
- timespec_incr(&t, timeout_us / SECOND, timeout_us * TS_USEC);
-
- if (ETIMEDOUT == pthread_cond_timedwait(&task_cond,
- &task_mutex, &t))
- task_event |= TASK_EVENT_TIMER;
- } else {
- pthread_cond_wait(&task_cond, &task_mutex);
- }
-
- pthread_mutex_unlock(&task_mutex);
- event = task_event;
- task_event = 0;
- return event;
-}
-
-uint32_t task_set_event(task_id_t tskid, /* always LIGHTBAR */
- uint32_t event)
-{
- pthread_mutex_lock(&task_mutex);
- task_event = event;
- pthread_cond_signal(&task_cond);
- pthread_mutex_unlock(&task_mutex);
- return 0;
-}
-
-
-
-/* Stubbed functions */
-
-void cprintf(int zero, const char *fmt, ...)
-{
- va_list ap;
- char *s;
- char *newfmt = strdup(fmt);
-
- for (s = newfmt; *s; s++)
- if (*s == '%' && s[1] == 'T')
- *s = 'T';
-
- va_start(ap, fmt);
- vprintf(newfmt, ap);
- va_end(ap);
-
- free(newfmt);
-}
-
-void cprints(int zero, const char *fmt, ...)
-{
- va_list ap;
-
- printf("[TT ");
- va_start(ap, fmt);
- vprintf(fmt, ap);
- va_end(ap);
- printf("]\n");
-}
-
-timestamp_t get_time(void)
-{
- static struct timespec t_start;
- struct timespec t;
- timestamp_t ret;
-
- if (!t_start.tv_sec)
- clock_gettime(CLOCK_REALTIME, &t_start);
- clock_gettime(CLOCK_REALTIME, &t);
- ret.val = (t.tv_sec - t_start.tv_sec) * SECOND +
- (t.tv_nsec - t_start.tv_nsec) / TS_USEC;
- return ret;
-}
-
-/* We could implement these if we wanted to test their usage. */
-int system_add_jump_tag(uint16_t tag, int version, int size, const void *data)
-{
- return 0;
-}
-
-uint8_t *system_get_jump_tag(uint16_t tag, int *version, int *size)
-{
- return 0;
-}
-
-/* Copied from util/ectool.c */
-int lb_read_params_from_file(const char *filename,
- struct lightbar_params_v1 *p)
-{
- FILE *fp;
- char buf[80];
- int val[4];
- int r = 1;
- int line = 0;
- int want, got;
- int i;
-
- fp = fopen(filename, "rb");
- if (!fp) {
- fprintf(stderr, "Can't open %s: %s\n",
- filename, strerror(errno));
- return 1;
- }
-
- /* We must read the correct number of params from each line */
-#define READ(N) do { \
- line++; \
- want = (N); \
- got = -1; \
- if (!fgets(buf, sizeof(buf), fp)) \
- goto done; \
- got = sscanf(buf, "%i %i %i %i", \
- &val[0], &val[1], &val[2], &val[3]); \
- if (want != got) \
- goto done; \
- } while (0)
-
-
- /* Do it */
- READ(1); p->google_ramp_up = val[0];
- READ(1); p->google_ramp_down = val[0];
- READ(1); p->s3s0_ramp_up = val[0];
- READ(1); p->s0_tick_delay[0] = val[0];
- READ(1); p->s0_tick_delay[1] = val[0];
- READ(1); p->s0a_tick_delay[0] = val[0];
- READ(1); p->s0a_tick_delay[1] = val[0];
- READ(1); p->s0s3_ramp_down = val[0];
- READ(1); p->s3_sleep_for = val[0];
- READ(1); p->s3_ramp_up = val[0];
- READ(1); p->s3_ramp_down = val[0];
- READ(1); p->tap_tick_delay = val[0];
- READ(1); p->tap_gate_delay = val[0];
- READ(1); p->tap_display_time = val[0];
-
- READ(1); p->tap_pct_red = val[0];
- READ(1); p->tap_pct_green = val[0];
- READ(1); p->tap_seg_min_on = val[0];
- READ(1); p->tap_seg_max_on = val[0];
- READ(1); p->tap_seg_osc = val[0];
- READ(3);
- p->tap_idx[0] = val[0];
- p->tap_idx[1] = val[1];
- p->tap_idx[2] = val[2];
-
- READ(2);
- p->osc_min[0] = val[0];
- p->osc_min[1] = val[1];
- READ(2);
- p->osc_max[0] = val[0];
- p->osc_max[1] = val[1];
- READ(2);
- p->w_ofs[0] = val[0];
- p->w_ofs[1] = val[1];
-
- READ(2);
- p->bright_bl_off_fixed[0] = val[0];
- p->bright_bl_off_fixed[1] = val[1];
-
- READ(2);
- p->bright_bl_on_min[0] = val[0];
- p->bright_bl_on_min[1] = val[1];
-
- READ(2);
- p->bright_bl_on_max[0] = val[0];
- p->bright_bl_on_max[1] = val[1];
-
- READ(3);
- p->battery_threshold[0] = val[0];
- p->battery_threshold[1] = val[1];
- p->battery_threshold[2] = val[2];
-
- READ(4);
- p->s0_idx[0][0] = val[0];
- p->s0_idx[0][1] = val[1];
- p->s0_idx[0][2] = val[2];
- p->s0_idx[0][3] = val[3];
-
- READ(4);
- p->s0_idx[1][0] = val[0];
- p->s0_idx[1][1] = val[1];
- p->s0_idx[1][2] = val[2];
- p->s0_idx[1][3] = val[3];
-
- READ(4);
- p->s3_idx[0][0] = val[0];
- p->s3_idx[0][1] = val[1];
- p->s3_idx[0][2] = val[2];
- p->s3_idx[0][3] = val[3];
-
- READ(4);
- p->s3_idx[1][0] = val[0];
- p->s3_idx[1][1] = val[1];
- p->s3_idx[1][2] = val[2];
- p->s3_idx[1][3] = val[3];
-
- for (i = 0; i < ARRAY_SIZE(p->color); i++) {
- READ(3);
- p->color[i].r = val[0];
- p->color[i].g = val[1];
- p->color[i].b = val[2];
- }
-
-#undef READ
-
- /* Yay */
- r = 0;
-done:
- if (r)
- fprintf(stderr, "problem with line %d: wanted %d, got %d\n",
- line, want, got);
- fclose(fp);
- return r;
-}
-
-int lb_load_program(const char *filename, struct lightbar_program *prog)
-{
- FILE *fp;
- size_t got;
- int rc;
-
- fp = fopen(filename, "rb");
- if (!fp) {
- fprintf(stderr, "Can't open %s: %s\n",
- filename, strerror(errno));
- return 1;
- }
-
- rc = fseek(fp, 0, SEEK_END);
- if (rc) {
- fprintf(stderr, "Couldn't find end of file %s",
- filename);
- fclose(fp);
- return 1;
- }
- rc = (int) ftell(fp);
- if (rc > EC_LB_PROG_LEN) {
- fprintf(stderr, "File %s is too long, aborting\n", filename);
- fclose(fp);
- return 1;
- }
- rewind(fp);
-
- memset(prog->data, 0, EC_LB_PROG_LEN);
- got = fread(prog->data, 1, EC_LB_PROG_LEN, fp);
- if (rc != got)
- fprintf(stderr, "Warning: did not read entire file\n");
- prog->size = got;
- fclose(fp);
- return 0;
-}
diff --git a/extra/lightbar/programs/bad-decode-32.bin b/extra/lightbar/programs/bad-decode-32.bin
deleted file mode 100644
index 1d5d0c6c75..0000000000
--- a/extra/lightbar/programs/bad-decode-32.bin
+++ /dev/null
@@ -1 +0,0 @@
-UUU \ No newline at end of file
diff --git a/extra/lightbar/programs/bad-decode-8.bin b/extra/lightbar/programs/bad-decode-8.bin
deleted file mode 100644
index 8352675d67..0000000000
--- a/extra/lightbar/programs/bad-decode-8.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/bad-jump.bin b/extra/lightbar/programs/bad-jump.bin
deleted file mode 100644
index b2c29a0bbf..0000000000
--- a/extra/lightbar/programs/bad-jump.bin
+++ /dev/null
@@ -1 +0,0 @@
-? \ No newline at end of file
diff --git a/extra/lightbar/programs/bad-opcode.bin b/extra/lightbar/programs/bad-opcode.bin
deleted file mode 100644
index 6b10f95843..0000000000
--- a/extra/lightbar/programs/bad-opcode.bin
+++ /dev/null
@@ -1 +0,0 @@
-Ã \ No newline at end of file
diff --git a/extra/lightbar/programs/green-pulse.bin b/extra/lightbar/programs/green-pulse.bin
deleted file mode 100644
index 0fdab712e9..0000000000
--- a/extra/lightbar/programs/green-pulse.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/green-pulse.lbs b/extra/lightbar/programs/green-pulse.lbs
deleted file mode 100644
index bccf3e5c9a..0000000000
--- a/extra/lightbar/programs/green-pulse.lbs
+++ /dev/null
@@ -1,8 +0,0 @@
- set.1 {0,1,2,3}.end.g 0xff
- delay.r 7813
- delay.w 2000000
-L0001: on
- cycle.1
- off
- wait
- jump L0001
diff --git a/extra/lightbar/programs/infinite-jump.bin b/extra/lightbar/programs/infinite-jump.bin
deleted file mode 100644
index 5407bf3ddf..0000000000
--- a/extra/lightbar/programs/infinite-jump.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/infinite-jump.lbs b/extra/lightbar/programs/infinite-jump.lbs
deleted file mode 100644
index 6174d7ffd4..0000000000
--- a/extra/lightbar/programs/infinite-jump.lbs
+++ /dev/null
@@ -1 +0,0 @@
-L0001: jump L0001
diff --git a/extra/lightbar/programs/konami.bin b/extra/lightbar/programs/konami.bin
deleted file mode 100644
index f7abfdc4ee..0000000000
--- a/extra/lightbar/programs/konami.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/konami.lbs b/extra/lightbar/programs/konami.lbs
deleted file mode 100644
index c9fa8d697a..0000000000
--- a/extra/lightbar/programs/konami.lbs
+++ /dev/null
@@ -1,89 +0,0 @@
-# Konami code easter egg
- delay.w 100000
- set.rgb {1,2}.end 0xff 0xff 0x00
- ramp.1
- wait
- cycle.1
- wait
- ramp.1
- wait
- cycle.1
- wait
- set.rgb {1,2}.end 0x00 0x00 0x00
- set.1 {0,3}.end.b 0xff
- ramp.1
- wait
- cycle.1
- wait
- ramp.1
- wait
- cycle.1
- wait
- set.1 {0,3}.end.b 0x00
- set.1 {0,1}.end.r 0xff
- ramp.1
- wait
- cycle.1
- wait
- set.1 {0,1}.end.r 0x00
- set.1 {2,3}.end.g 0xff
- ramp.1
- wait
- cycle.1
- wait
- set.1 {2,3}.end.g 0x00
- set.1 {0,1}.end.r 0xff
- ramp.1
- wait
- cycle.1
- wait
- set.1 {0,1}.end.r 0x00
- set.1 {2,3}.end.g 0xff
- ramp.1
- wait
- cycle.1
- wait
- set.1 {2,3}.end.g 0x00
- set.rgb {0,2}.end 0x00 0xff 0xff
- ramp.1
- wait
- cycle.1
- wait
- delay.w 50000
- wait
- set.rgb {0,2}.end 0x00 0x00 0x00
- set.rgb {1,3}.end 0xff 0x00 0xff
- ramp.1
- wait
- wait
- cycle.1
- wait
- delay.w 100000
- wait
- wait
- set.rgb {0,1,2,3}.end 0xff 0xff 0xff
- ramp.1
- wait
- cycle.1
- wait
- ramp.1
- wait
- cycle.1
- wait
- ramp.1
- wait
- cycle.1
- wait
- ramp.1
- wait
- cycle.1
- wait
- ramp.1
- wait
- cycle.1
- wait
- ramp.1
- wait
- cycle.1
- wait
- halt
diff --git a/extra/lightbar/programs/rainbow-shift.bin b/extra/lightbar/programs/rainbow-shift.bin
deleted file mode 100644
index a72c5b16d6..0000000000
--- a/extra/lightbar/programs/rainbow-shift.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/rainbow-shift.lbs b/extra/lightbar/programs/rainbow-shift.lbs
deleted file mode 100644
index e1cbcddc83..0000000000
--- a/extra/lightbar/programs/rainbow-shift.lbs
+++ /dev/null
@@ -1,8 +0,0 @@
-# The rainbow cycle program.
- set.rgb {0,1,2,3}.end 0xff 0xff 0xff
- set.rgb {0}.phase 0x00 0x55 0xaa
- set.rgb {1}.phase 0x40 0x95 0xea
- set.rgb {2}.phase 0x80 0xd5 0x2a
- set.rgb {3}.phase 0xc0 0x15 0x6a
- delay.r 7813
- cycle
diff --git a/extra/lightbar/programs/red-green-blink.bin b/extra/lightbar/programs/red-green-blink.bin
deleted file mode 100644
index 6bece444dd..0000000000
--- a/extra/lightbar/programs/red-green-blink.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/red-green-blink.lbs b/extra/lightbar/programs/red-green-blink.lbs
deleted file mode 100644
index d520b739bb..0000000000
--- a/extra/lightbar/programs/red-green-blink.lbs
+++ /dev/null
@@ -1,14 +0,0 @@
-# Blinks red and green with 1 second pauses.
- set.rgb {0,1,2,3}.beg 0xff 0x00 0x00
- set.rgb {0,1,2,3}.end 0x00 0xff 0x00
- delay.w 250000
- delay.r 0
- cycle.1
- wait
- ramp.1
- wait
- cycle.1
- wait
- ramp.1
- wait
- halt
diff --git a/extra/lightbar/programs/s0.bin b/extra/lightbar/programs/s0.bin
deleted file mode 100644
index b20cecd8ee..0000000000
--- a/extra/lightbar/programs/s0.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/s0.lbs b/extra/lightbar/programs/s0.lbs
deleted file mode 100644
index 364c3d595c..0000000000
--- a/extra/lightbar/programs/s0.lbs
+++ /dev/null
@@ -1,22 +0,0 @@
-# S0 sequence: Google colors, unless battery is low.
- set.rgb {0}.end 0x33 0x69 0xe8
- set.rgb {1}.end 0xd5 0x0f 0x25
- set.rgb {2}.end 0xee 0xb2 0x11
- set.rgb {3}.end 0x00 0x99 0x25
- delay.r 1250
- ramp.1
- set.1 {0,1,2,3}.beg.r 0xff
- delay.r 2500
- delay.w 1000000
- wait
- jump L0003
-L0001: swap
- ramp.1
-L0002: wait
-L0003: jbat L0004 L0002
- jump L0002
-L0004: swap
- ramp.1
-L0005: wait
- jbat L0005 L0001
- jump L0001
diff --git a/extra/lightbar/programs/s0s3.bin b/extra/lightbar/programs/s0s3.bin
deleted file mode 100644
index d1cb8a4af1..0000000000
--- a/extra/lightbar/programs/s0s3.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/s0s3.lbs b/extra/lightbar/programs/s0s3.lbs
deleted file mode 100644
index ba141f338d..0000000000
--- a/extra/lightbar/programs/s0s3.lbs
+++ /dev/null
@@ -1,16 +0,0 @@
-# S0S3 sequence: Fade out, Google color ramp up/down.
- get
- delay.r 2000
- ramp.1
- swap
- set.rgb {0}.end 0x33 0x69 0xe8
- set.rgb {1}.end 0xd5 0x0f 0x25
- set.rgb {2}.end 0xee 0xb2 0x11
- set.rgb {3}.end 0x00 0x99 0x25
- delay.r 1250
- ramp.1
- swap
- delay.r 10000
- ramp.1
- off
- halt
diff --git a/extra/lightbar/programs/s3.bin b/extra/lightbar/programs/s3.bin
deleted file mode 100644
index 7e487bb8c9..0000000000
--- a/extra/lightbar/programs/s3.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/s3.lbs b/extra/lightbar/programs/s3.lbs
deleted file mode 100644
index e8803a06bb..0000000000
--- a/extra/lightbar/programs/s3.lbs
+++ /dev/null
@@ -1,17 +0,0 @@
-# S3 sequence: Pulse red on low battery.
- set.rgb {0,1,2,3}.end 0xff 0x00 0x00
- cycle.1
- delay.w 5000000
-L0001: off
- wait
- jcharge L0001
- jbat L0002 L0001
- jump L0001
-L0002: on
- delay.r 1250
- ramp.1
- swap
- delay.r 10000
- ramp.1
- swap
- jump L0001
diff --git a/extra/lightbar/programs/s3s0.bin b/extra/lightbar/programs/s3s0.bin
deleted file mode 100644
index b277752d25..0000000000
--- a/extra/lightbar/programs/s3s0.bin
+++ /dev/null
Binary files differ
diff --git a/extra/lightbar/programs/s3s0.lbs b/extra/lightbar/programs/s3s0.lbs
deleted file mode 100644
index 0cac96f208..0000000000
--- a/extra/lightbar/programs/s3s0.lbs
+++ /dev/null
@@ -1,11 +0,0 @@
-# S3S0 sequence: Google color ramp up/down.
- set.rgb {0}.end 0x33 0x69 0xe8
- set.rgb {1}.end 0xd5 0x0f 0x25
- set.rgb {2}.end 0xee 0xb2 0x11
- set.rgb {3}.end 0x00 0x99 0x25
- delay.r 1250
- ramp.1
- swap
- delay.r 10000
- ramp.1
- halt
diff --git a/extra/lightbar/simulation.h b/extra/lightbar/simulation.h
deleted file mode 100644
index 4df7b69411..0000000000
--- a/extra/lightbar/simulation.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef __EXTRA_SIMULATION_H
-#define __EXTRA_SIMULATION_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "lb_common.h"
-#include "lightbar.h"
-
-/* Functions specific to our simulation environment */
-void *entry_windows(void *);
-void *entry_input(void *);
-void *entry_lightbar(void *);
-void init_windows(void);
-int lb_read_params_from_file(const char *filename,
- struct lightbar_params_v1 *p);
-int lb_load_program(const char *filename, struct lightbar_program *prog);
-/* Interfaces to the EC code that we're encapsulating */
-void lightbar_task(void);
-int fake_consolecmd_lightbar(int argc, char *argv[]);
-
-/* EC-specific configuration */
-#undef DEMO_MODE_DEFAULT
-#define DEMO_MODE_DEFAULT 1
-#ifndef CONFIG_CONSOLE_CMDHELP
-#define CONFIG_CONSOLE_CMDHELP
-#endif
-#ifndef CONFIG_LIGHTBAR_POWER_RAILS
-#define CONFIG_LIGHTBAR_POWER_RAILS
-#endif
-
-
-/* Stuff that's too interleaved with the rest of the EC to just include */
-
-/* Test an important condition at compile time, not run time */
-#define _BA1_(cond, line) \
- extern int __build_assertion_ ## line[1 - 2*!(cond)] \
- __attribute__ ((unused))
-#define _BA0_(c, x) _BA1_(c, x)
-#define BUILD_ASSERT(cond) _BA0_(cond, __LINE__)
-
-#define BUILD_CHECK_INLINE(value, cond_true) ((value) / (!!(cond_true)))
-
-/* Number of elements in an array */
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
-/* Non-standard standard library functions */
-void cprintf(int zero, const char *fmt, ...);
-void cprints(int zero, const char *fmt, ...);
-#define ccprintf(fmt...) cprintf(0, fmt)
-#define strtoi strtol
-
-/* Task events */
-#define TASK_EVENT_CUSTOM_BIT(x) BUILD_CHECK_INLINE(BIT(x), BIT(x) & 0x0fffffff)
-#define TASK_EVENT_I2C_IDLE 0x10000000
-#define TASK_EVENT_WAKE 0x20000000
-#define TASK_EVENT_MUTEX 0x40000000
-#define TASK_EVENT_TIMER 0x80000000
-
-/* Time units in usecs */
-#define MSEC 1000
-#define SECOND 1000000
-
-#define TASK_ID_LIGHTBAR 0
-#define CC_LIGHTBAR 0
-
-/* Other definitions and structs */
-#define EC_SUCCESS 0
-#define EC_ERROR_INVAL 5
-#define EC_ERROR_PARAM1 11
-#define EC_ERROR_PARAM2 12
-
-typedef int task_id_t;
-
-typedef union {
- uint64_t val;
- struct {
- uint32_t lo;
- uint32_t hi;
- } le /* little endian words */;
-} timestamp_t;
-
-struct host_cmd_handler_args {
- const void *params;
- void *response;
- int response_size;
-};
-
-/* EC functions that we have to provide */
-uint32_t task_wait_event(int timeout_us);
-uint32_t task_set_event(task_id_t tskid, uint32_t event);
-timestamp_t get_time(void);
-int system_add_jump_tag(uint16_t tag, int version, int size, const void *data);
-uint8_t *system_get_jump_tag(uint16_t tag, int *version, int *size);
-
-/* Export unused static functions to avoid compiler warnings. */
-#define DECLARE_HOOK(X, fn, Y) \
- void fake_hook_##fn(void) { fn(); }
-
-#define DECLARE_HOST_COMMAND(X, fn, Y) \
- enum ec_status fake_hostcmd_##fn(struct host_cmd_handler_args *args) \
- { return fn(args); }
-
-#define DECLARE_CONSOLE_COMMAND(X, fn, Y...) \
- int fake_consolecmd_##X(int argc, char *argv[]) \
- { return fn(argc, argv); }
-
-#endif /* __EXTRA_SIMULATION_H */
diff --git a/extra/lightbar/windows.c b/extra/lightbar/windows.c
deleted file mode 100644
index 115074363c..0000000000
--- a/extra/lightbar/windows.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Copyright 2014 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <assert.h>
-#include <pthread.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <xcb/xcb.h>
-
-#include "simulation.h"
-
-/*****************************************************************************/
-/* Window drawing stuff */
-
-/* Dimensions - may change */
-static int win_w = 1024;
-static int win_h = 32;
-
-static xcb_connection_t *c;
-static xcb_screen_t *screen;
-static xcb_drawable_t win;
-static xcb_gcontext_t foreground;
-static xcb_colormap_t colormap_id;
-
-static int fake_power;
-
-void init_windows(void)
-{
- uint32_t mask = 0;
- uint32_t values[2];
-
- /* Open the connection to the X server */
- c = xcb_connect(NULL, NULL);
-
- /* Get the first screen */
- screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
-
- /* Get a colormap */
- colormap_id = xcb_generate_id(c);
- xcb_create_colormap(c, XCB_COLORMAP_ALLOC_NONE,
- colormap_id, screen->root, screen->root_visual);
-
- /* Create foreground GC */
- foreground = xcb_generate_id(c);
- mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
- values[0] = screen->white_pixel;
- values[1] = 0;
- xcb_create_gc(c, foreground, screen->root, mask, values);
-
- /* Create the window */
- win = xcb_generate_id(c);
- mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
- values[0] = screen->black_pixel;
- values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS;
- xcb_create_window(c, /* Connection */
- XCB_COPY_FROM_PARENT, /* depth */
- win, /* window Id */
- screen->root, /* parent window */
- 0, 0, /* x, y */
- win_w, win_h, /* width, height */
- 10, /* border_width */
- XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */
- screen->root_visual, /* visual */
- mask, values); /* masks */
-
- /* Map the window on the screen */
- xcb_map_window(c, win);
-
- /* We flush the request */
- xcb_flush(c);
-}
-
-void cleanup(void)
-{
- xcb_destroy_window(c, win);
- xcb_free_gc(c, foreground);
- xcb_free_colormap(c, colormap_id);
- xcb_disconnect(c);
-}
-
-/*****************************************************************************/
-/* Draw the lightbar elements */
-
-/* xcb likes 16-bit colors */
-uint16_t leds[NUM_LEDS][3] = {
- {0xffff, 0x0000, 0x0000},
- {0x0000, 0xffff, 0x0000},
- {0x0000, 0x0000, 0xffff},
- {0xffff, 0xffff, 0x0000},
-};
-pthread_mutex_t leds_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-void change_gc_color(uint16_t red, uint16_t green, uint16_t blue)
-{
- uint32_t mask = 0;
- uint32_t values[2];
- xcb_alloc_color_reply_t *reply;
-
- reply = xcb_alloc_color_reply(c,
- xcb_alloc_color(c, colormap_id,
- red, green, blue),
- NULL);
- assert(reply);
-
- mask = XCB_GC_FOREGROUND;
- values[0] = reply->pixel;
- xcb_change_gc(c, foreground, mask, values);
- free(reply);
-}
-
-void update_window(void)
-{
- xcb_segment_t segments[] = {
- {0, 0, win_w, win_h},
- {0, win_h, win_w, 0},
- };
- xcb_rectangle_t rect;
- int w = win_w / NUM_LEDS;
- int i;
- uint16_t copyleds[NUM_LEDS][3];
-
- if (fake_power) {
- pthread_mutex_lock(&leds_mutex);
- memcpy(copyleds, leds, sizeof(leds));
- pthread_mutex_unlock(&leds_mutex);
-
- for (i = 0; i < NUM_LEDS; i++) {
- rect.x = i * w;
- rect.y = 0;
- rect.width = w;
- rect.height = win_h;
-
- change_gc_color(copyleds[i][0],
- copyleds[i][1],
- copyleds[i][2]);
-
- xcb_poly_fill_rectangle(c, win, foreground, 1, &rect);
- }
- } else {
- rect.x = 0;
- rect.y = 0;
- rect.width = win_w;
- rect.height = win_h;
-
- change_gc_color(0, 0, 0);
- xcb_poly_fill_rectangle(c, win, foreground, 1, &rect);
-
- change_gc_color(0x8080, 0, 0);
-
- for (i = 0; i < NUM_LEDS; i++) {
- segments[0].x1 = i * w;
- segments[0].y1 = 0;
- segments[0].x2 = segments[0].x1 + w;
- segments[0].y2 = win_h;
- segments[1].x1 = segments[0].x1;
- segments[1].y1 = win_h;
- segments[1].x2 = segments[0].x2;
- segments[1].y2 = 0;
- xcb_poly_segment(c, win, foreground, 2, segments);
- }
- }
-
- xcb_flush(c);
-}
-
-void setrgb(int led, int red, int green, int blue)
-{
- led %= NUM_LEDS;
-
- pthread_mutex_lock(&leds_mutex);
- leds[led][0] = red << 8 | red;
- leds[led][1] = green << 8 | green;
- leds[led][2] = blue << 8 | blue;
- pthread_mutex_unlock(&leds_mutex);
-
- update_window();
-}
-
-/*****************************************************************************/
-/* lb_common stubs */
-
-
-
-/* Brightness serves no purpose here. It's automatic on the Chromebook. */
-static int brightness = 0xc0;
-void lb_set_brightness(unsigned int newval)
-{
- brightness = newval;
-}
-uint8_t lb_get_brightness(void)
-{
- return brightness;
-}
-
-void lb_set_rgb(unsigned int led, int red, int green, int blue)
-{
- int i;
- if (led >= NUM_LEDS)
- for (i = 0; i < NUM_LEDS; i++)
- setrgb(i, red, green, blue);
- else
- setrgb(led, red, green, blue);
-}
-
-int lb_get_rgb(unsigned int led, uint8_t *red, uint8_t *green, uint8_t *blue)
-{
- led %= NUM_LEDS;
- pthread_mutex_lock(&leds_mutex);
- *red = leds[led][0];
- *green = leds[led][1];
- *blue = leds[led][2];
- pthread_mutex_unlock(&leds_mutex);
- return 0;
-}
-
-void lb_init(void)
-{
- if (fake_power)
- lb_set_rgb(NUM_LEDS, 0, 0, 0);
-};
-void lb_off(void)
-{
- fake_power = 0;
- update_window();
-};
-void lb_on(void)
-{
- fake_power = 1;
- update_window();
-};
-void lb_hc_cmd_dump(struct ec_response_lightbar *out)
-{
- printf("lightbar is %s\n", fake_power ? "on" : "off");
- memset(out, fake_power, sizeof(*out));
-};
-void lb_hc_cmd_reg(const struct ec_params_lightbar *in) { };
-
-int lb_power(int enabled)
-{
- return fake_power;
-}
-
-
-/*****************************************************************************/
-/* Event handling stuff */
-
-void *entry_windows(void *ptr)
-{
- xcb_generic_event_t *e;
- xcb_expose_event_t *ev;
- xcb_button_press_event_t *bv;
- int chg = 1;
-
- while ((e = xcb_wait_for_event(c))) {
-
- switch (e->response_type & ~0x80) {
- case XCB_EXPOSE:
- ev = (xcb_expose_event_t *)e;
- if (win_w != ev->width || win_h != ev->height) {
- win_w = ev->width;
- win_h = ev->height;
- }
- update_window();
- break;
- case XCB_BUTTON_PRESS:
- bv = (xcb_button_press_event_t *)e;
- switch (bv->detail) {
- case 1:
- demo_battery_level(-1);
- break;
- case 3:
- demo_battery_level(+1);
- break;
- case 2:
- chg = !chg;
- demo_is_charging(chg);
- break;
- }
- break;
- }
-
- free(e);
- }
-
- cleanup();
- exit(0);
- return 0;
-}