Skip to content

Commit

Permalink
fix power sensor patch
Browse files Browse the repository at this point in the history
  • Loading branch information
BoukeHaarsma23 committed Jul 24, 2023
1 parent dfa07a4 commit 387d601
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
52 changes: 39 additions & 13 deletions pkgs/mangohud/0001-Use-k10-temp-power-sensors-if-exist.patch
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
From 20033beb012ad2e6d342c1e412afc426f2b32bd1 Mon Sep 17 00:00:00 2001
From 1053a6988291f79d7ce6143f57e7add1098fc6e0 Mon Sep 17 00:00:00 2001
From: Bouke Haarsma <[email protected]>
Date: Sun, 23 Jul 2023 21:54:26 +0200
Subject: [PATCH] Use k10-temp power sensors if exist

---
src/cpu.cpp | 17 ++++++++++++++++-
src/cpu.cpp | 22 ++++++++++++++++++++++
src/cpu.h | 6 ++++++
2 files changed, 22 insertions(+), 1 deletion(-)
2 files changed, 28 insertions(+)

diff --git a/src/cpu.cpp b/src/cpu.cpp
index a33873987c..ee92b7bb9e 100644
index a338739..1619c65 100644
--- a/src/cpu.cpp
+++ b/src/cpu.cpp
@@ -296,9 +296,24 @@ bool CPUStats::UpdateCpuTemp() {
@@ -296,6 +296,21 @@ bool CPUStats::UpdateCpuTemp() {
static bool get_cpu_power_k10temp(CPUPowerData* cpuPowerData, float& power) {
CPUPowerData_k10temp* powerData_k10temp = (CPUPowerData_k10temp*)cpuPowerData;

- if (!powerData_k10temp->coreVoltageFile || !powerData_k10temp->coreCurrentFile || !powerData_k10temp->socVoltageFile || !powerData_k10temp->socCurrentFile)
+ if (!powerData_k10temp->coreVoltageFile || !powerData_k10temp->coreCurrentFile || !powerData_k10temp->socVoltageFile || !powerData_k10temp->socCurrentFile || !powerData_k10temp->corePowerFile || !powerData_k10temp->socPowerFile)
return false;

+ if(powerData_k10temp->corePowerFile || powerData_k10temp->socPowerFile)
+ {
+ rewind(powerData_k10temp->corePowerFile);
Expand All @@ -35,11 +31,40 @@ index a33873987c..ee92b7bb9e 100644
+ return true;
+ }
+ voltagebased:
rewind(powerData_k10temp->coreVoltageFile);
rewind(powerData_k10temp->coreCurrentFile);
rewind(powerData_k10temp->socVoltageFile);
if (!powerData_k10temp->coreVoltageFile || !powerData_k10temp->coreCurrentFile || !powerData_k10temp->socVoltageFile || !powerData_k10temp->socCurrentFile)
return false;

@@ -494,21 +509,28 @@ static CPUPowerData_k10temp* init_cpu_power_data_k10temp(const std::string path)

std::string coreVoltageInput, coreCurrentInput;
std::string socVoltageInput, socCurrentInput;
+ std::string socPowerInput, corePowerInput;

if(!find_input(path, "in", coreVoltageInput, "Vcore")) return nullptr;
if(!find_input(path, "curr", coreCurrentInput, "Icore")) return nullptr;
if(!find_input(path, "in", socVoltageInput, "Vsoc")) return nullptr;
if(!find_input(path, "curr", socCurrentInput, "Isoc")) return nullptr;
+ if(!find_input(path, "power", corePowerInput, "Pcore")) return nullptr;
+ if(!find_input(path, "power", socPowerInput, "Psoc")) return nullptr;

SPDLOG_DEBUG("hwmon: using input: {}", coreVoltageInput);
SPDLOG_DEBUG("hwmon: using input: {}", coreCurrentInput);
SPDLOG_DEBUG("hwmon: using input: {}", socVoltageInput);
SPDLOG_DEBUG("hwmon: using input: {}", socCurrentInput);
+ SPDLOG_DEBUG("hwmon: using input: {}", corePowerInput);
+ SPDLOG_DEBUG("hwmon: using input: {}", socPowerInput);

powerData->coreVoltageFile = fopen(coreVoltageInput.c_str(), "r");
powerData->coreCurrentFile = fopen(coreCurrentInput.c_str(), "r");
powerData->socVoltageFile = fopen(socVoltageInput.c_str(), "r");
powerData->socCurrentFile = fopen(socCurrentInput.c_str(), "r");
+ powerData->socPowerFile = fopen(socPowerInput.c_str(), "r");
+ powerData->corePowerFile = fopen(corePowerInput.c_str(), "r");

return powerData.release();
}
diff --git a/src/cpu.h b/src/cpu.h
index ed91d98f0d..ef31735e69 100644
index ed91d98..ef31735 100644
--- a/src/cpu.h
+++ b/src/cpu.h
@@ -72,12 +72,18 @@ struct CPUPowerData_k10temp : public CPUPowerData {
Expand All @@ -63,3 +88,4 @@ index ed91d98f0d..ef31735e69 100644
struct CPUPowerData_zenpower : public CPUPowerData {
--
2.41.0

2 changes: 1 addition & 1 deletion pkgs/mangohud/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sha256sums=(
'b94997df68856753b72f0d7a3703b7d484d4745c567f3584ef97c96c25a5798e'
'53361271cfe274df8782e1e47bdc9e61b7af432ba30acbfe31723f9df2c257f3'
'860358cf5e73f458cd1e88f8c38116d123ab421d5ce2e4129ec38eaedd820e17'
'1aa439a66b5b46505d6039fbca00fb8dd9d0ac454a9babcaadd732f94f84e534'
'b5980e5c708d54f406b13dd3fa116406469fa57dc207eb11f5e9404d24950995'
)

_build_args="-Dappend_libdir_mangohud=false -Dwith_xnvctrl=disabled -Dmangoapp_layer=true"
Expand Down

0 comments on commit 387d601

Please sign in to comment.