shithub: riscv

Download patch

ref: 878911b628207d05a1cf829235e61112bcae59f5
parent: 2968225196d6078203e88d26572a51216f545c1d
author: Sigrid <[email protected]>
date: Fri Sep 25 06:28:25 EDT 2020

aux/acpi: connect EC region handler, fixes battery status on eeepc 1000px (thanks Peter Kosyh)

--- a/sys/src/cmd/aux/acpi.c
+++ b/sys/src/cmd/aux/acpi.c
@@ -84,7 +84,42 @@
 	{{Qctl},			"ctl",		0666,		ctlread,		ctlwrite},
 };
 
+static char*
+eisaid(void *v)
+{
+	static char id[8];
+	ulong b, l;
+	int i;
+
+	if(amltag(v) == 's')
+		return v;
+	b = amlint(v);
+	for(l = 0, i=24; i>=0; i -= 8, b >>= 8)
+		l |= (b & 0xFF) << i;
+	id[7] = 0;
+	for(i=6; i>=3; i--, l >>= 4)
+		id[i] = "0123456789ABCDEF"[l & 0xF];
+	for(i=2; i>=0; i--, l >>= 5)
+		id[i] = '@' + (l & 0x1F);
+	return id;
+}
+
 static int
+enumec(void *dot, void *)
+{
+	void *p;
+	char *id;
+	id = eisaid(amlval(amlwalk(dot, "^_HID")));
+	if (id == nil || strcmp(id, "PNP0C09") != 0)
+		return 1;
+	p = amlwalk(dot, "^_REG");
+	if (p != nil) {
+		amleval(p, "ii", 0x3, 1, nil);
+	}
+	return 1;
+}
+
+static int
 enumbat(void *dot, void *)
 {
 	void *p, *r, **rr;
@@ -501,6 +536,7 @@
 	}
 	close(fd);
 
+	amlenum(amlroot, "_HID", enumec, nil);
 	amlenum(amlroot, "_BIF", enumbat, nil);
 	amlenum(amlroot, "_PSL", enumtmp, nil);