#include <hw/thermal.h>
#include <hw/shared.h>
-#define THERMAL_PATH "/sys/class/sec/temperature/ap_therm"
+#define AP_PATH "/sys/class/sec/temperature/ap_therm"
+#define BATTERY_PATH "/sys/class/sec/temperature/batt_therm"
static struct event_data {
ThermalUpdated updated_cb;
static guint timer;
-static int thermal_get_info(struct thermal_info *info)
+static int thermal_get_info(device_thermal_e type, struct thermal_info *info)
{
FILE *fp;
char buf[32];
if (!info)
return -EINVAL;
- fp = fopen(THERMAL_PATH, "r");
+ if (type == DEVICE_THERMAL_BATTERY)
+ fp = fopen(BATTERY_PATH, "r");
+ else
+ fp = fopen(AP_PATH, "r");
+
if (!fp) {
- _E("Failed to open %s(%d)", THERMAL_PATH, errno);
+ _E("Failed to open thermal path(%d)", errno);
return -errno;
}
len = fread(buf, 1, sizeof(buf) - 1, fp);
fclose(fp);
if (len == 0) {
- _E("Failed to read %s(%d)", THERMAL_PATH, errno);
+ _E("Failed to read thermal value(%d)", errno);
return -errno;
}
buf[len] = '\0';
}
info->adc = atoi(ret + 4); /* 4 == strlen("adc:") */
- _I("AP temp(%d) adc(%d)", info->temp, info->adc);
+ _I("temp(%d) adc(%d)", info->temp, info->adc);
return 0;
}
struct thermal_info info;
int ret;
- ret = thermal_get_info(&info);
+ ret = thermal_get_info(DEVICE_THERMAL_AP, &info);
if (ret < 0) {
- _E("Failed to read thermal state (%d)", ret);
+ _E("Failed to read thermal info (%d)", ret);
return G_SOURCE_CONTINUE;
}