ports/70039: [ maintainer ] sysutils/torsmo: add some acpi stuff
Roman Bogorodskiy
bogorodskiy at inbox.ru
Thu Aug 5 16:00:45 UTC 2004
>Number: 70039
>Category: ports
>Synopsis: [ maintainer ] sysutils/torsmo: add some acpi stuff
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: maintainer-update
>Submitter-Id: current-users
>Arrival-Date: Thu Aug 05 16:00:44 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator: Roman Bogorodskiy
>Release: FreeBSD 5.2.1-RELEASE-p9 i386
>Organization:
>Environment:
System: FreeBSD lame.novel.ru 5.2.1-RELEASE-p9 FreeBSD 5.2.1-RELEASE-p9 #11: Thu Aug 5 07:58:46 MSD 2004 root at lame.novel.ru:/usr/obj/usr/src/sys/NOV i386
>Description:
Add ACPI support patch by Anton Karpov <toxa at cterra.ru> with some
modifications.
>How-To-Repeat:
>Fix:
diff -ruN torsmo.orig/files/freebsd.c torsmo/files/freebsd.c
--- torsmo.orig/files/freebsd.c Thu Aug 5 19:40:18 2004
+++ torsmo/files/freebsd.c Thu Aug 5 19:41:06 2004
@@ -28,6 +28,7 @@
void net_init();
#define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
+#define KELVTOC(x) ((x - 2732) / 10.0)
static int getsysctl(char *name, void *ptr, size_t len)
{
@@ -291,14 +292,27 @@
}
double get_acpi_temperature(int fd) {
- double temp;
+ double temp;
- temp = 0;
-
- return temp;
+ if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
+ (void)fprintf(stderr, "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
+ temp = -1.0;
+ }
+
+ return KELVTOC(temp);
}
void get_battery_stuff(char *buf, unsigned int n, int b) {
+ int battime;
+
+ if (GETSYSCTL("hw.acpi.battery.time", battime))
+ (void)fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n");
+
+ if (battime != -1)
+ snprintf(buf, n, "Discharging, remaining %d:%2.2d", battime / 60, battime % 60);
+ else
+ snprintf(buf, n, "Battery is charging");
+
}
int open_i2c_sensor(const char *dev, const char *type, int n, int *div)
@@ -312,9 +326,23 @@
char* get_acpi_ac_adapter(void)
{
- return "blah";
+ int state;
+ char *acstate = (char*)malloc(100);
+
+ if (GETSYSCTL("hw.acpi.acline", state)) {
+ (void)fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
+ return "n\\a";
+ }
+
+ if (state)
+ strcpy(acstate,"Running on AC Power");
+ else
+ strcpy(acstate, "Running on battery");
+
+ return acstate;
}
char* get_acpi_fan() {
+
return "";
}
diff -ruN torsmo.orig/files/patch-torsmo.c torsmo/files/patch-torsmo.c
--- torsmo.orig/files/patch-torsmo.c Thu Jan 1 03:00:00 1970
+++ torsmo/files/patch-torsmo.c Thu Aug 5 19:40:32 2004
@@ -0,0 +1,11 @@
+--- torsmo.c.orig Thu Aug 5 19:39:06 2004
++++ torsmo.c Thu Aug 5 19:39:20 2004
+@@ -998,7 +998,7 @@
+ }
+ OBJ(acpitemp) {
+ /* does anyone have decimals in acpi temperature? */
+- snprintf(p, n, "%d", (int) get_acpi_temperature(obj->data.i));
++ snprintf(p, n, "%0.1f", (int) get_acpi_temperature(obj->data.i));
+ }
+ OBJ(acpifan) {
+ snprintf(p, n, "%s", get_acpi_fan());
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list