summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorParth Malkan <parthmalkan@google.com>2022-06-29 14:39:49 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-07 02:39:32 +0000
commit785da78da7dfb37f9bdfb57f22a696a656a0b931 (patch)
tree07cbd4fd0b74e1e955a32f1c730c1fa6ec76e67f /util
parentfa3766d2e4a13c228caf88c122eb6dfc30bd1818 (diff)
downloadchrome-ec-785da78da7dfb37f9bdfb57f22a696a656a0b931.tar.gz
ectool: rgbkbd: Add getconfig support
Usage: ectool rgbkbd getconfig Returns RGB KB type - Number of LEDs and zones BUG=b:237592750 BRANCH=none TEST=Tested on Taniks and Vell Cq-Depend: chromium:3732802 Change-Id: Ia58c648865e8bca2f073770b54a3b0f529f35abf Signed-off-by: Parth Malkan <parthmalkan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3735915 Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c80
1 files changed, 53 insertions, 27 deletions
diff --git a/util/ectool.c b/util/ectool.c
index d80a3404cf..24fc49763f 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -1288,22 +1288,25 @@ int cmd_reboot_ap_on_g3(int argc, char *argv[])
static void cmd_rgbkbd_help(char *cmd)
{
fprintf(stderr,
- " Usage1: %s <key> <RGB> [<RGB> ...]\n"
- " Set the color of <key> to <RGB>. Multiple colors for\n"
- " adjacent keys can be set at once.\n"
- "\n"
- " Usage2: %s clear <RGB>\n"
- " Set the color of all keys to <RGB>.\n"
- "\n"
- " Usage3: %s demo <num>\n"
- " Run demo-<num>. 0: Off, 1: Flow, 2: Dot.\n"
- "\n"
- " Usage4: %s scale <key> <val>\n"
- " Set the scale parameter of key_<key> to <val>.\n"
- " <val> is a 24-bit integer where scale values are encoded\n"
- " as R=23:16, G=15:8, B=7:0.\n"
- "\n",
- cmd, cmd, cmd, cmd);
+ " Usage1: %s <key> <RGB> [<RGB> ...]\n"
+ " Set the color of <key> to <RGB>. Multiple colors for\n"
+ " adjacent keys can be set at once.\n"
+ "\n"
+ " Usage2: %s clear <RGB>\n"
+ " Set the color of all keys to <RGB>.\n"
+ "\n"
+ " Usage3: %s demo <num>\n"
+ " Run demo-<num>. 0: Off, 1: Flow, 2: Dot.\n"
+ "\n"
+ " Usage4: %s scale <key> <val>\n"
+ " Set the scale parameter of key_<key> to <val>.\n"
+ " <val> is a 24-bit integer where scale values are encoded\n"
+ " as R=23:16, G=15:8, B=7:0.\n"
+ "\n"
+ " Usage5: %s getconfig\n"
+ " Get the HW config supported.\n"
+ "\n",
+ cmd, cmd, cmd, cmd, cmd);
}
static int cmd_rgbkbd_parse_rgb_text(const char *text, struct rgb_s *color)
@@ -1368,26 +1371,23 @@ static int cmd_rgbkbd(int argc, char *argv[])
int val;
char *e;
int rv = -1;
- ;
+ struct ec_params_rgbkbd p;
+ struct ec_response_rgbkbd r;
- if (argc < 3) {
+ if (argc < 2) {
cmd_rgbkbd_help(argv[0]);
return -1;
}
if (argc == 3 && !strcasecmp(argv[1], "clear")) {
/* Usage 2 */
- struct ec_params_rgbkbd p;
-
p.subcmd = EC_RGBKBD_SUBCMD_CLEAR;
if (cmd_rgbkbd_parse_rgb_text(argv[2], &p.color))
return -1;
- rv = ec_command(EC_CMD_RGBKBD, 0, &p, sizeof(p), NULL, 0);
+ rv = ec_command(EC_CMD_RGBKBD, 0, &p, sizeof(p), &r, 0);
} else if (argc == 3 && !strcasecmp(argv[1], "demo")) {
/* Usage 3 */
- struct ec_params_rgbkbd p;
-
val = strtol(argv[2], &e, 0);
if ((e && *e) || val >= EC_RGBKBD_DEMO_COUNT) {
fprintf(stderr, "Invalid demo id: %s\n", argv[2]);
@@ -1395,11 +1395,9 @@ static int cmd_rgbkbd(int argc, char *argv[])
}
p.subcmd = EC_RGBKBD_SUBCMD_DEMO;
p.demo = val;
- rv = ec_command(EC_CMD_RGBKBD, 0, &p, sizeof(p), NULL, 0);
+ rv = ec_command(EC_CMD_RGBKBD, 0, &p, sizeof(p), &r, 0);
} else if (argc == 4 && !strcasecmp(argv[1], "scale")) {
/* Usage 4 */
- struct ec_params_rgbkbd p;
-
val = strtol(argv[2], &e, 0);
if ((e && *e) || val > EC_RGBKBD_MAX_KEY_COUNT) {
fprintf(stderr, "Invalid key number: %s\n", argv[2]);
@@ -1411,7 +1409,35 @@ static int cmd_rgbkbd(int argc, char *argv[])
return -1;
}
p.subcmd = EC_RGBKBD_SUBCMD_SET_SCALE;
- rv = ec_command(EC_CMD_RGBKBD, 0, &p, sizeof(p), NULL, 0);
+ rv = ec_command(EC_CMD_RGBKBD, 0, &p, sizeof(p), &r, 0);
+ } else if (argc == 2 && !strcasecmp(argv[1], "getconfig")) {
+ /* Usage 5 */
+ char *type;
+
+ p.subcmd = EC_RGBKBD_SUBCMD_GET_CONFIG;
+ rv = ec_command(EC_CMD_RGBKBD, 0, &p, sizeof(p), &r, sizeof(r));
+
+ if (rv < 0)
+ return rv;
+
+ switch ((enum ec_rgbkbd_type)r.rgbkbd_type) {
+ case EC_RGBKBD_TYPE_PER_KEY:
+ type = "EC_RGBKBD_TYPE_PER_KEY";
+ break;
+ case EC_RGBKBD_TYPE_FOUR_ZONES_40_LEDS:
+ type = "EC_RGBKBD_TYPE_FOUR_ZONES_40_LEDS";
+ break;
+ case EC_RGBKBD_TYPE_FOUR_ZONES_12_LEDS:
+ type = "EC_RGBKBD_TYPE_FOUR_ZONES_12_LEDS";
+ break;
+ case EC_RGBKBD_TYPE_FOUR_ZONES_15_LEDS:
+ type = "EC_RGBKBD_TYPE_FOUR_ZONES_15_LEDS";
+ break;
+ default:
+ type = "EC_RGBKBD_TYPE_UNKNOWN";
+ }
+
+ printf("RGBKBD_TYPE: %s\n", type);
} else {
/* Usage 1 */
rv = cmd_rgbkbd_set_color(argc, argv);