mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-13 11:25:14 +00:00
CEC: Add cecset/cecget to ectool
Set and get CEC parameters. Currently supported parameters are "enable" and "address" Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org> BUG=b:76467407 BRANCH=none TEST=Using EC firmware with CEC support, set values and read them back. CQ-DEPEND=CL:1030217 Change-Id: I429710f5d8897b23c5b5e54bd10cbf38d1830811 Reviewed-on: https://chromium-review.googlesource.com/1030218 Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org> Tested-by: Stefan Adolfsson <sadolfsson@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
1c941f01db
commit
436dd71e5d
@@ -76,6 +76,10 @@ const char help_str[] =
|
||||
" Prints supported version mask for a command number\n"
|
||||
" console\n"
|
||||
" Prints the last output to the EC debug console\n"
|
||||
" cecset <address|enable> <val>\n"
|
||||
" Set the value of a CEC setting\n"
|
||||
" cecget <address|enable>\n"
|
||||
" Get the value of a CEC setting\n"
|
||||
" cecread [timeout]\n"
|
||||
" Read data from the CEC bus\n"
|
||||
" cecwrite [write bytes...]\n"
|
||||
@@ -7935,6 +7939,74 @@ int cmd_cec_read(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cec_cmd_from_str(const char *str)
|
||||
{
|
||||
if (!strcmp("address", str))
|
||||
return CEC_CMD_LOGICAL_ADDRESS;
|
||||
if (!strcmp("enable", str))
|
||||
return CEC_CMD_ENABLE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int cmd_cec_set(int argc, char *argv[])
|
||||
{
|
||||
char *e;
|
||||
struct ec_params_cec_set p;
|
||||
uint8_t val;
|
||||
int cmd;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Usage: %s [address|enable] param\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
val = (uint8_t)strtol(argv[2], &e, 0);
|
||||
if (e && *e) {
|
||||
fprintf(stderr, "Bad parameter '%s'.\n", argv[2]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmd = cec_cmd_from_str(argv[1]);
|
||||
if (cmd < 0) {
|
||||
fprintf(stderr, "Invalid command '%s'.\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
p.cmd = cmd;
|
||||
p.val = val;
|
||||
|
||||
return ec_command(EC_CMD_CEC_SET,
|
||||
0, &p, sizeof(p), NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
int cmd_cec_get(int argc, char *argv[])
|
||||
{
|
||||
int rv, cmd;
|
||||
struct ec_params_cec_get p;
|
||||
struct ec_response_cec_get r;
|
||||
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s [address|enable]\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmd = cec_cmd_from_str(argv[1]);
|
||||
if (cmd < 0) {
|
||||
fprintf(stderr, "Invalid command '%s'.\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
p.cmd = cmd;
|
||||
|
||||
|
||||
rv = ec_command(EC_CMD_CEC_GET, 0, &p, sizeof(p), &r, sizeof(r));
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
|
||||
printf("%d\n", r.val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* NULL-terminated list of commands */
|
||||
const struct command commands[] = {
|
||||
@@ -7954,6 +8026,8 @@ const struct command commands[] = {
|
||||
{"console", cmd_console},
|
||||
{"cecwrite", cmd_cec_write},
|
||||
{"cecread", cmd_cec_read},
|
||||
{"cecset", cmd_cec_set},
|
||||
{"cecget", cmd_cec_get},
|
||||
{"echash", cmd_ec_hash},
|
||||
{"eventclear", cmd_host_event_clear},
|
||||
{"eventclearb", cmd_host_event_clear_b},
|
||||
|
||||
Reference in New Issue
Block a user