smarter gpu figuriung out

This commit is contained in:
drath
2025-08-28 15:12:37 +02:00
parent 69f16b5b43
commit 6e3815ca05
3 changed files with 53 additions and 31 deletions

View File

@@ -175,13 +175,13 @@ int main(int argc, char *argv[]) {
cpu_hwmon = findHwmonPath("zenpower");
}
/* figure out gpu path */
/* figure out gpu metrics path */
std::string gpu_hwmon;
GpuMetricsHeader_t gpu_mtr_rev;
GpuMetricsHeader_t gpu_mtr_header;
for (uint8_t c = 0; c < 10; c++) {
gpu_hwmon = "/sys/class/drm/card" + std::to_string(c) + "/device";
gpu_mtr_rev = getGpuMetricsHeader(gpu_hwmon + "/gpu_metrics");
if (gpu_mtr_rev.structure_size > 0)
gpu_mtr_header = getGpuMetricsHeader(gpu_hwmon + "/gpu_metrics");
if (readFile(gpu_hwmon + "/board_info").length() != 0)
break;
}
@@ -200,7 +200,9 @@ int main(int argc, char *argv[]) {
auto ram = getRam();
// auto anime = getDisk("/mnt/anime");
auto home = getDisk("/home/drath");
auto gpu = getGpu(gpu_mtr_rev, gpu_hwmon);
// auto gpu = (gpu_mtr_header.structure_size != 0) ? getGpu(gpu_mtr_header, gpu_hwmon) : getGpu("/sys/class/drm/card1/device");
auto gpu = getGpu(gpu_mtr_header, gpu_hwmon);
auto cpu = getCpuTemp(cpu_hwmon);
lines[0] = pad(td[1], 11, true) + " " + td[0] + lcd.bar(1, gpu.core_usage / 100.0) + pad(getAvgs(), 17);
@@ -209,7 +211,10 @@ int main(int argc, char *argv[]) {
lines[1] += pad(pBytes(ram.used, true) + "B", 7, true);
lines[1] += fill(7);
lines[1] += pad(pBytes(gpu.vram_used) + "B", 7);
lines[1] += pad(std::to_string(gpu.edge_temp) + "/" + std::to_string(gpu.hotspot_temp) + "/" + std::to_string(gpu.mem_temp) + lcd.cc[0], 11);
auto gpu_temps = (gpu.hotspot_temp) ? "/" + std::to_string(gpu.hotspot_temp) : "";
gpu_temps += (gpu.mem_temp) ? "/" + std::to_string(gpu.mem_temp) : "";
lines[1] += pad(std::to_string(gpu.edge_temp) + gpu_temps + lcd.cc[0], 11);
lines[2] = pad(pNum(cpu.ptotal, 1) + "W", 8, true);
lines[2] += pad("home: " + pBytes(home.free), 12);