netstar pushed a commit to branch master. http://git.enlightenment.org/apps/evisum.git/commit/?id=856b3acd1366f74db75b98dd7f9a02803745e7b5
commit 856b3acd1366f74db75b98dd7f9a02803745e7b5 Author: Alastair Poole <nets...@gmail.com> Date: Sun Oct 11 11:26:49 2020 +0100 cpu: distinguish between thermal drivers. Each cpu arch is likely to have varying behaviours, as added, for each the behaviour needs to be taken into account. This is Linux only... --- src/bin/system/machine/cpu.bogox | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/bin/system/machine/cpu.bogox b/src/bin/system/machine/cpu.bogox index 92606c6..e9c1f4e 100644 --- a/src/bin/system/machine/cpu.bogox +++ b/src/bin/system/machine/cpu.bogox @@ -20,6 +20,12 @@ # define CPU_STATES 5 #endif +typedef enum { + THERMAL_UNKNOWN = 0, + THERMAL_INTEL_CORETEMP = 1, + THERMAL_AMD_AMDTEMP = 2, +} thermal_drv_t; + static int cpu_count(void) { @@ -315,6 +321,7 @@ system_cpu_n_temperature_get(int n) #if defined(__linux__) static int init = 0; int cpu_count, i; + thermal_drv_t type = THERMAL_UNKNOWN; if (!init) { @@ -344,7 +351,10 @@ system_cpu_n_temperature_get(int n) if (b) { if (!strncmp(b, "coretemp", 8)) - snprintf(_hwmon_path, sizeof(_hwmon_path), "%s", link); + { + snprintf(_hwmon_path, sizeof(_hwmon_path), "%s", link); + type = THERMAL_INTEL_CORETEMP; + } free(b); } free(link); @@ -359,11 +369,12 @@ system_cpu_n_temperature_get(int n) if (_core_temps[n][0]) return _cpu_n_temperature_read(n); - cpu_count = system_cpu_count_get(); - i = 1 + ((cpu_count + n) / 2) - (cpu_count / 2); - - snprintf(_core_temps[n], sizeof(_core_temps[n]), "%s/temp%d_input", _hwmon_path, i); - + if (type == THERMAL_INTEL_CORETEMP) + { + cpu_count = system_cpu_count_get(); + i = 1 + ((cpu_count + n) / 2) - (cpu_count / 2); + snprintf(_core_temps[n], sizeof(_core_temps[n]), "%s/temp%d_input", _hwmon_path, i); + } return _cpu_n_temperature_read(n); #elif defined(__FreeBSD__) || defined(__DragonFly__) static int init = 0; --