aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/modules/temperature/e_mod_main.c7
-rw-r--r--src/modules/temperature/e_mod_main.h2
-rw-r--r--src/modules/temperature/e_mod_main_private.h1
-rw-r--r--src/modules/temperature/tempget.c61
4 files changed, 69 insertions, 2 deletions
diff --git a/src/modules/temperature/e_mod_main.c b/src/modules/temperature/e_mod_main.c
index e46f73d81..0d061db5e 100644
--- a/src/modules/temperature/e_mod_main.c
+++ b/src/modules/temperature/e_mod_main.c
@@ -6,6 +6,13 @@
#include <sys/sysctl.h>
#endif
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/sensors.h>
+#endif
+
+
/* gadcon requirements */
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
static void _gc_shutdown(E_Gadcon_Client *gcc);
diff --git a/src/modules/temperature/e_mod_main.h b/src/modules/temperature/e_mod_main.h
index c91f1b6c3..83b3ce43e 100644
--- a/src/modules/temperature/e_mod_main.h
+++ b/src/modules/temperature/e_mod_main.h
@@ -45,7 +45,7 @@ struct _Config_Face
Ecore_Event_Handler *tempget_del_handler;
Eina_Bool have_temp:1;
-#ifdef __FreeBSD__
+#if defined (__FreeBSD__) || defined (__OpenBSD__)
int mib[5];
#endif
};
diff --git a/src/modules/temperature/e_mod_main_private.h b/src/modules/temperature/e_mod_main_private.h
index dbbf65909..232859a9d 100644
--- a/src/modules/temperature/e_mod_main_private.h
+++ b/src/modules/temperature/e_mod_main_private.h
@@ -5,6 +5,7 @@ typedef enum _Sensor_Type
{
SENSOR_TYPE_NONE,
SENSOR_TYPE_FREEBSD,
+ SENSOR_TYPE_OPENBSD,
SENSOR_TYPE_OMNIBOOK,
SENSOR_TYPE_LINUX_MACMINI,
SENSOR_TYPE_LINUX_I2C,
diff --git a/src/modules/temperature/tempget.c b/src/modules/temperature/tempget.c
index bbe2556e2..7a403cc5a 100644
--- a/src/modules/temperature/tempget.c
+++ b/src/modules/temperature/tempget.c
@@ -11,6 +11,14 @@
# include <sys/sysctl.h>
#endif
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/sensors.h>
+#include <errno.h>
+#include <err.h>
+#endif
+
#include <Ecore.h>
#include <Ecore_File.h>
@@ -22,9 +30,18 @@ static int poll_interval = 32;
static int cur_poll_interval = 32;
static char *sensor_path = NULL;
-#ifdef __FreeBSD__
+#if defined (__FreeBSD__) || defined (__OpenBSD__)
static int mib[5];
#endif
+
+#ifdef __OpenBSD__
+static int dev, numt;
+static struct sensordev snsrdev;
+static size_t sdlen = sizeof(snsrdev);
+static struct sensor snsr;
+static size_t slen = sizeof(snsr);
+#endif
+
static Ecore_Poller *poller = NULL;
static int ptemp = 0;
@@ -93,6 +110,24 @@ init(void)
/* TODO: FreeBSD can also have more temperature sensors! */
sensor_type = SENSOR_TYPE_FREEBSD;
sensor_name = strdup("tz0");
+#elif __OpenBSD__
+ mib[0] = CTL_HW;
+ mib[1] = HW_SENSORS;
+
+ for (dev = 0; ; dev++) {
+ mib[2] = dev;
+ if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1) {
+ if (errno == ENOENT) /* no further sensors */
+ break;
+ else
+ continue;
+ }
+ if (strcmp(snsrdev.xname, "cpu0") == 0) {
+ sensor_type = SENSOR_TYPE_OPENBSD;
+ sensor_name = strdup("cpu0");
+ break;
+ }
+ }
#else
therms = ecore_file_ls("/proc/acpi/thermal_zone");
if (therms)
@@ -235,6 +270,20 @@ init(void)
sysctlnametomib(sensor_path, mib, &len);
#endif
break;
+ case SENSOR_TYPE_OPENBSD:
+#ifdef __OpenBSD__
+ for (numt = 0; numt < snsrdev.maxnumt[SENSOR_TEMP]; numt++) {
+ mib[4] = numt;
+ slen = sizeof(snsr);
+ if (sysctl(mib, 5, &snsr, &slen, NULL, 0) == -1)
+ continue;
+ if (slen > 0 && (snsr.flags & SENSOR_FINVALID) == 0) {
+ break;
+ }
+ }
+#endif
+
+ break;
case SENSOR_TYPE_OMNIBOOK:
sensor_path = strdup("/proc/omnibook/temperature");
break;
@@ -335,6 +384,16 @@ check(void)
goto error;
#endif
break;
+ case SENSOR_TYPE_OPENBSD:
+#ifdef __OpenBSD__
+ if (sysctl(mib, 5, &snsr, &slen, NULL, 0) != -1) {
+ temp = (snsr.value - 273150000) / 1000000.0;
+ ret = 1;
+ }
+ else
+ goto error;
+#endif
+ break;
case SENSOR_TYPE_OMNIBOOK:
f = fopen(sensor_path, "r");
if (f)