Loki LED control should check for EC state which requires patching ectool to provide it.
This commit is contained in:
parent
9dd414edcc
commit
31862c6dd0
2 changed files with 73 additions and 0 deletions
|
@ -23,6 +23,7 @@ RGB_GREEN="0xB1"
|
|||
RGB_BLUE="0xB2"
|
||||
RGB_MODE="0xB3"
|
||||
RGB_SAVE="0xAA"
|
||||
RGB_IDLE="0x55"
|
||||
|
||||
ECTOOL="/usr/sbin/ectool"
|
||||
DEBUG=false
|
||||
|
@ -32,6 +33,19 @@ function debug_out() {
|
|||
}
|
||||
|
||||
function ec_save() {
|
||||
TIMEOUT=0
|
||||
while true
|
||||
do
|
||||
STATE="0x$(${ECTOOL} -r ${RGB_MODE})"
|
||||
if [ "${STATE^^}" == "${RGB_SAVE}" ] || \
|
||||
[ "${STATE}" == "${RGB_IDLE}" ] || \
|
||||
[ "${TIMEOUT}" == 5 ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
sleep .5
|
||||
TIMEOUT=$(( TIMEOUT + 1 ))
|
||||
done
|
||||
${ECTOOL} -w ${RGB_MODE} -z ${RGB_SAVE} >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
|
59
packages/sysutils/ectool/patches/001-read.patch
Normal file
59
packages/sysutils/ectool/patches/001-read.patch
Normal file
|
@ -0,0 +1,59 @@
|
|||
diff --git a/util/ectool/ectool.c b/util/ectool/ectool.c
|
||||
index cb6f280f4c..585ae5faf1 100644
|
||||
--- a/util/ectool/ectool.c
|
||||
+++ b/util/ectool/ectool.c
|
||||
@@ -52,6 +52,7 @@ void print_usage(const char *name)
|
||||
" -d | --dump: print RAM\n"
|
||||
" -i | --idx: print IDX RAM & RAM\n"
|
||||
" -q | --query: print query byte\n"
|
||||
+ " -r <addr in hex> read from addr\n"
|
||||
" -w <addr in hex> write to addr\n"
|
||||
" -z <data in hex> write to data\n"
|
||||
"\n");
|
||||
@@ -65,6 +66,7 @@ int main(int argc, char *argv[])
|
||||
int i, opt, option_index = 0;
|
||||
long write_data = -1;
|
||||
long write_addr = -1;
|
||||
+ long read_addr = -1;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"version", 0, 0, 'v'},
|
||||
@@ -81,7 +83,7 @@ int main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
- while ((opt = getopt_long(argc, argv, "vh?Vidqpw:z:",
|
||||
+ while ((opt = getopt_long(argc, argv, "vh?Vidqpr:w:z:",
|
||||
long_options, &option_index)) != EOF) {
|
||||
switch (opt) {
|
||||
case 'v':
|
||||
@@ -95,6 +97,9 @@ int main(int argc, char *argv[])
|
||||
dump_idx = 1;
|
||||
dump_ram = 1;
|
||||
break;
|
||||
+ case 'r':
|
||||
+ read_addr = strtol(optarg , NULL, 16);
|
||||
+ break;
|
||||
case 'w':
|
||||
write_addr = strtol(optarg , NULL, 16);
|
||||
break;
|
||||
@@ -133,6 +138,7 @@ int main(int argc, char *argv[])
|
||||
printf("You need to be root.\n");
|
||||
exit(1);
|
||||
}
|
||||
+
|
||||
if (write_addr >= 0 && write_data >= 0) {
|
||||
write_addr &= 0xff;
|
||||
write_data &= 0xff;
|
||||
@@ -140,6 +146,11 @@ int main(int argc, char *argv[])
|
||||
ec_write(write_addr & 0xff, write_data & 0xff);
|
||||
}
|
||||
|
||||
+ if (read_addr >= 0) {
|
||||
+ printf("%02x", ec_read(read_addr));
|
||||
+ exit(0);
|
||||
+ }
|
||||
+
|
||||
/* preserve default - dump_ram if nothing selected */
|
||||
if (!dump_ram && !dump_idx && !dump_query && (write_addr == -1))
|
||||
dump_ram = 1;
|
Loading…
Reference in a new issue