forked from enlightenment/enlightenment
temp module patches to make it work again.
SVN revision: 33685
This commit is contained in:
parent
0c3c93f9ad
commit
44191ab9cf
|
@ -125,7 +125,43 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
||||||
case SENSOR_TYPE_LINUX_INTELCORETEMP:
|
case SENSOR_TYPE_LINUX_INTELCORETEMP:
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_LINUX_I2C:
|
case SENSOR_TYPE_LINUX_I2C:
|
||||||
therms = temperature_get_i2c_files();
|
therms = temperature_get_bus_files("i2c");
|
||||||
|
if (therms)
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
while ((name = ecore_list_next(therms)))
|
||||||
|
{
|
||||||
|
if (ecore_file_exists(name))
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
sprintf(path, "%s", ecore_file_file_get(name));
|
||||||
|
len = strlen(path);
|
||||||
|
if (len > 6)
|
||||||
|
path[len - 6] = '\0';
|
||||||
|
ecore_list_append(cfdata->sensors, strdup(path));
|
||||||
|
/* TODO: Track down the user friendly names and display them instead.
|
||||||
|
* User friendly names are not available on the system, lm-sensors
|
||||||
|
* contains a database in /etc/sensors.conf, but the format may change,
|
||||||
|
* so the best way to use that database is thru libsensors, but we
|
||||||
|
* don't want to add any more library dependencies.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ecore_list_destroy(therms);
|
||||||
|
}
|
||||||
|
|
||||||
|
ecore_list_first_goto(cfdata->sensors);
|
||||||
|
while ((name = ecore_list_next(cfdata->sensors)))
|
||||||
|
{
|
||||||
|
if (!strcmp(cfdata->inst->sensor_name, name))
|
||||||
|
break;
|
||||||
|
cfdata->sensor++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SENSOR_TYPE_LINUX_PCI:
|
||||||
|
therms = temperature_get_bus_files("pci");
|
||||||
if (therms)
|
if (therms)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
|
@ -407,54 +407,57 @@ temperature_face_update_config(Config_Face *inst)
|
||||||
}
|
}
|
||||||
|
|
||||||
Ecore_List *
|
Ecore_List *
|
||||||
temperature_get_i2c_files()
|
temperature_get_bus_files(const char* bus)
|
||||||
{
|
{
|
||||||
Ecore_List *result;
|
Ecore_List *result;
|
||||||
Ecore_List *therms;
|
Ecore_List *therms;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
char busdir[PATH_MAX];
|
||||||
|
|
||||||
result = ecore_list_new();
|
result = ecore_list_new();
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
ecore_list_free_cb_set(result, free);
|
ecore_list_free_cb_set(result, free);
|
||||||
|
snprintf(busdir, sizeof(busdir), "/sys/bus/%s/devices", bus);
|
||||||
/* Look through all the i2c devices. */
|
/* Look through all the devices for the given bus. */
|
||||||
therms = ecore_file_ls("/sys/bus/i2c/devices");
|
therms = ecore_file_ls(busdir);
|
||||||
if (therms)
|
if (therms)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
while ((name = ecore_list_next(therms)))
|
while ((name = ecore_list_next(therms)))
|
||||||
{
|
{
|
||||||
Ecore_List *files;
|
Ecore_List *files;
|
||||||
|
|
||||||
/* Search each device for temp*_input, these should be i2c temperature devices. */
|
/* Search each device for temp*_input, these should be
|
||||||
sprintf(path, "/sys/bus/i2c/devices/%s", name);
|
* temperature devices. */
|
||||||
files = ecore_file_ls(path);
|
snprintf(path, sizeof(path),
|
||||||
if (files)
|
"%s/%s", busdir, name);
|
||||||
{
|
files = ecore_file_ls(path);
|
||||||
char *file;
|
if (files)
|
||||||
|
{
|
||||||
while ((file = ecore_list_next(files)))
|
char *file;
|
||||||
{
|
|
||||||
if ((strncmp("temp", file, 4) == 0) && (strcmp("_input", &file[strlen(file) - 6]) == 0))
|
while ((file = ecore_list_next(files)))
|
||||||
|
{
|
||||||
|
if ((!strncmp("temp", file, 4)) &&
|
||||||
|
(!strcmp("_input", &file[strlen(file) - 6])))
|
||||||
{
|
{
|
||||||
char *f;
|
char *f;
|
||||||
|
|
||||||
sprintf(path, "/sys/bus/i2c/devices/%s/%s", name, file);
|
snprintf(path, sizeof(path),
|
||||||
f = strdup(path);
|
"%s/%s/%s", busdir, name, file);
|
||||||
if (f)
|
f = strdup(path);
|
||||||
ecore_list_append(result, f);
|
if (f) ecore_list_append(result, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ecore_list_destroy(files);
|
ecore_list_destroy(files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ecore_list_destroy(therms);
|
ecore_list_destroy(therms);
|
||||||
}
|
}
|
||||||
ecore_list_first_goto(result);
|
ecore_list_first_goto(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ typedef enum _Sensor_Type
|
||||||
SENSOR_TYPE_LINUX_MACMINI,
|
SENSOR_TYPE_LINUX_MACMINI,
|
||||||
SENSOR_TYPE_LINUX_I2C,
|
SENSOR_TYPE_LINUX_I2C,
|
||||||
SENSOR_TYPE_LINUX_ACPI,
|
SENSOR_TYPE_LINUX_ACPI,
|
||||||
|
SENSOR_TYPE_LINUX_PCI,
|
||||||
SENSOR_TYPE_LINUX_PBOOK,
|
SENSOR_TYPE_LINUX_PBOOK,
|
||||||
SENSOR_TYPE_LINUX_INTELCORETEMP
|
SENSOR_TYPE_LINUX_INTELCORETEMP
|
||||||
} Sensor_Type;
|
} Sensor_Type;
|
||||||
|
@ -69,7 +70,7 @@ EAPI int e_modapi_save (E_Module *m);
|
||||||
|
|
||||||
void config_temperature_module(Config_Face *inst);
|
void config_temperature_module(Config_Face *inst);
|
||||||
void temperature_face_update_config(Config_Face *inst);
|
void temperature_face_update_config(Config_Face *inst);
|
||||||
Ecore_List *temperature_get_i2c_files(void);
|
Ecore_List *temperature_get_bus_files(const char* bus);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,18 +26,20 @@ static int check(void);
|
||||||
static int poll_cb(void *data);
|
static int poll_cb(void *data);
|
||||||
|
|
||||||
Ecore_List *
|
Ecore_List *
|
||||||
temperature_get_i2c_files()
|
temperature_get_bus_files(const char* bus)
|
||||||
{
|
{
|
||||||
Ecore_List *result;
|
Ecore_List *result;
|
||||||
Ecore_List *therms;
|
Ecore_List *therms;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
char busdir[PATH_MAX];
|
||||||
|
|
||||||
result = ecore_list_new();
|
result = ecore_list_new();
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
ecore_list_free_cb_set(result, free);
|
ecore_list_free_cb_set(result, free);
|
||||||
/* Look through all the i2c devices. */
|
snprintf(busdir, sizeof(busdir), "/sys/bus/%s/devices", bus);
|
||||||
therms = ecore_file_ls("/sys/bus/i2c/devices");
|
/* Look through all the devices for the given bus. */
|
||||||
|
therms = ecore_file_ls(busdir);
|
||||||
if (therms)
|
if (therms)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -47,9 +49,9 @@ temperature_get_i2c_files()
|
||||||
Ecore_List *files;
|
Ecore_List *files;
|
||||||
|
|
||||||
/* Search each device for temp*_input, these should be
|
/* Search each device for temp*_input, these should be
|
||||||
* i2c temperature devices. */
|
* temperature devices. */
|
||||||
snprintf(path, sizeof(path),
|
snprintf(path, sizeof(path),
|
||||||
"/sys/bus/i2c/devices/%s", name);
|
"%s/%s", busdir, name);
|
||||||
files = ecore_file_ls(path);
|
files = ecore_file_ls(path);
|
||||||
if (files)
|
if (files)
|
||||||
{
|
{
|
||||||
|
@ -63,8 +65,7 @@ temperature_get_i2c_files()
|
||||||
char *f;
|
char *f;
|
||||||
|
|
||||||
snprintf(path, sizeof(path),
|
snprintf(path, sizeof(path),
|
||||||
"/sys/bus/i2c/devices/%s/%s",
|
"%s/%s/%s", busdir, name, file);
|
||||||
name, file);
|
|
||||||
f = strdup(path);
|
f = strdup(path);
|
||||||
if (f) ecore_list_append(result, f);
|
if (f) ecore_list_append(result, f);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +134,8 @@ init(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
therms = temperature_get_i2c_files();
|
// try the i2c bus
|
||||||
|
therms = temperature_get_bus_files("i2c");
|
||||||
if (therms)
|
if (therms)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -151,10 +153,44 @@ init(void)
|
||||||
sensor_type = SENSOR_TYPE_LINUX_I2C;
|
sensor_type = SENSOR_TYPE_LINUX_I2C;
|
||||||
sensor_path = strdup(name);
|
sensor_path = strdup(name);
|
||||||
sensor_name = strdup(path);
|
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);
|
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
|
#endif
|
||||||
|
@ -208,6 +244,28 @@ init(void)
|
||||||
ecore_list_destroy(therms);
|
ecore_list_destroy(therms);
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case SENSOR_TYPE_LINUX_ACPI:
|
||||||
snprintf(path, sizeof(path),
|
snprintf(path, sizeof(path),
|
||||||
"/proc/acpi/thermal_zone/%s/temperature",
|
"/proc/acpi/thermal_zone/%s/temperature",
|
||||||
|
@ -301,6 +359,25 @@ check(void)
|
||||||
else
|
else
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
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:
|
case SENSOR_TYPE_LINUX_ACPI:
|
||||||
f = fopen(sensor_path, "r");
|
f = fopen(sensor_path, "r");
|
||||||
if (f)
|
if (f)
|
||||||
|
|
Loading…
Reference in New Issue