aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/temperature/tempget.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2008-02-06 00:13:25 +0000
committerCarsten Haitzler <raster@rasterman.com>2008-02-06 00:13:25 +0000
commit44191ab9cf4fc58fd073b9f9e7341b13e63ab7aa (patch)
tree51b34fc8fba81417e96ea297572bf05747ddd071 /src/modules/temperature/tempget.c
parentFixed: Pointer sliding (focus) shouldn't happen when dragging in... (diff)
downloadenlightenment-44191ab9cf4fc58fd073b9f9e7341b13e63ab7aa.tar.gz
temp module patches to make it work again.
SVN revision: 33685
Diffstat (limited to 'src/modules/temperature/tempget.c')
-rw-r--r--src/modules/temperature/tempget.c93
1 files changed, 85 insertions, 8 deletions
diff --git a/src/modules/temperature/tempget.c b/src/modules/temperature/tempget.c
index cccdcc38f..1fe62a5b3 100644
--- a/src/modules/temperature/tempget.c
+++ b/src/modules/temperature/tempget.c
@@ -26,18 +26,20 @@ static int check(void);
static int poll_cb(void *data);
Ecore_List *
-temperature_get_i2c_files()
+temperature_get_bus_files(const char* bus)
{
Ecore_List *result;
Ecore_List *therms;
char path[PATH_MAX];
+ char busdir[PATH_MAX];
result = ecore_list_new();
if (result)
{
ecore_list_free_cb_set(result, free);
- /* Look through all the i2c devices. */
- therms = ecore_file_ls("/sys/bus/i2c/devices");
+ snprintf(busdir, sizeof(busdir), "/sys/bus/%s/devices", bus);
+ /* Look through all the devices for the given bus. */
+ therms = ecore_file_ls(busdir);
if (therms)
{
char *name;
@@ -47,9 +49,9 @@ temperature_get_i2c_files()
Ecore_List *files;
/* Search each device for temp*_input, these should be
- * i2c temperature devices. */
+ * temperature devices. */
snprintf(path, sizeof(path),
- "/sys/bus/i2c/devices/%s", name);
+ "%s/%s", busdir, name);
files = ecore_file_ls(path);
if (files)
{
@@ -63,8 +65,7 @@ temperature_get_i2c_files()
char *f;
snprintf(path, sizeof(path),
- "/sys/bus/i2c/devices/%s/%s",
- name, file);
+ "%s/%s/%s", busdir, name, file);
f = strdup(path);
if (f) ecore_list_append(result, f);
}
@@ -133,7 +134,8 @@ init(void)
}
else
{
- therms = temperature_get_i2c_files();
+ // try the i2c bus
+ therms = temperature_get_bus_files("i2c");
if (therms)
{
char *name;
@@ -151,10 +153,44 @@ init(void)
sensor_type = SENSOR_TYPE_LINUX_I2C;
sensor_path = strdup(name);
sensor_name = strdup(path);
+ printf("sensor type = i2c\n"
+ "sensor path = %s\n"
+ "sensor name = %s\n",
+ sensor_path, sensor_name);
}
}
ecore_list_destroy(therms);
}
+ if (!sensor_path)
+ {
+ // try the pci bus
+ therms = temperature_get_bus_files("pci");
+ if (therms)
+ {
+ char *name;
+
+ if ((name = ecore_list_next(therms)))
+ {
+ if (ecore_file_exists(name))
+ {
+ int len;
+
+ snprintf(path, sizeof(path),
+ "%s", ecore_file_file_get(name));
+ len = strlen(path);
+ if (len > 6) path[len - 6] = '\0';
+ sensor_type = SENSOR_TYPE_LINUX_PCI;
+ sensor_path = strdup(name);
+ sensor_name = strdup(path);
+ printf("sensor type = pci\n"
+ "sensor path = %s\n"
+ "sensor name = %s\n",
+ sensor_path, sensor_name);
+ }
+ }
+ ecore_list_destroy(therms);
+ }
+ }
}
}
#endif
@@ -208,6 +244,28 @@ init(void)
ecore_list_destroy(therms);
}
break;
+ case SENSOR_TYPE_LINUX_PCI:
+ therms = ecore_file_ls("/sys/bus/pci/devices");
+ if (therms)
+ {
+ char *name;
+
+ while ((name = ecore_list_next(therms)))
+ {
+ snprintf(path, sizeof(path),
+ "/sys/bus/pci/devices/%s/%s_input",
+ name, sensor_name);
+ if (ecore_file_exists(path))
+ {
+ sensor_path = strdup(path);
+ /* We really only care about the first
+ * one for the default. */
+ break;
+ }
+ }
+ ecore_list_destroy(therms);
+ }
+ break;
case SENSOR_TYPE_LINUX_ACPI:
snprintf(path, sizeof(path),
"/proc/acpi/thermal_zone/%s/temperature",
@@ -301,6 +359,25 @@ check(void)
else
goto error;
break;
+ case SENSOR_TYPE_LINUX_PCI:
+ f = fopen(sensor_path, "r");
+ if (f)
+ {
+ fgets(buf, sizeof(buf), f);
+ buf[sizeof(buf) - 1] = 0;
+
+ /* actually read the temp */
+ if (sscanf(buf, "%i", &temp) == 1)
+ ret = 1;
+ else
+ goto error;
+ /* Hack for temp */
+ temp = temp / 1000;
+ fclose(f);
+ }
+ else
+ goto error;
+ break;
case SENSOR_TYPE_LINUX_ACPI:
f = fopen(sensor_path, "r");
if (f)