Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 Aug 2004 19:52:12 +0400
From:      Roman Bogorodskiy <bogorodskiy@inbox.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/70039: [ maintainer ] sysutils/torsmo: add some acpi stuff
Message-ID:  <E1BskXL-000D0o-00.bogorodskiy-inbox-ru@mx1.mail.ru>
Resent-Message-ID: <200408051600.i75G0i5E028997@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@lame.novel.ru:/usr/obj/usr/src/sys/NOV i386


>Description:
	Add ACPI support patch by Anton Karpov <toxa@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1BskXL-000D0o-00.bogorodskiy-inbox-ru>