mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 03:02:49 +00:00
AMD GPU: Add temperature
That should be it for the AMD GPU part of https://github.com/scorpion-26/gBar/issues/5
This commit is contained in:
parent
27bb118d9a
commit
4373ab7654
1 changed files with 7 additions and 5 deletions
12
src/AMDGPU.h
12
src/AMDGPU.h
|
@ -9,6 +9,8 @@ namespace AMDGPU
|
||||||
static const char* utilizationFile = "/sys/class/drm/card0/device/gpu_busy_percent";
|
static const char* utilizationFile = "/sys/class/drm/card0/device/gpu_busy_percent";
|
||||||
static const char* vramTotalFile = "/sys/class/drm/card0/device/mem_info_vram_total";
|
static const char* vramTotalFile = "/sys/class/drm/card0/device/mem_info_vram_total";
|
||||||
static const char* vramUsedFile = "/sys/class/drm/card0/device/mem_info_vram_used";
|
static const char* vramUsedFile = "/sys/class/drm/card0/device/mem_info_vram_used";
|
||||||
|
// TODO: Make this configurable
|
||||||
|
static const char* tempFile = "/sys/class/drm/card0/device/hwmon/hwmon1/temp1_input";
|
||||||
|
|
||||||
inline void Init()
|
inline void Init()
|
||||||
{
|
{
|
||||||
|
@ -32,7 +34,6 @@ namespace AMDGPU
|
||||||
std::ifstream file(utilizationFile);
|
std::ifstream file(utilizationFile);
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(file, line);
|
std::getline(file, line);
|
||||||
LOG("AMD GetUtilization: " << line);
|
|
||||||
return atoi(line.c_str());
|
return atoi(line.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,8 +44,11 @@ namespace AMDGPU
|
||||||
LOG("Error: Called AMD GetTemperature, but AMD GPU wasn't found!");
|
LOG("Error: Called AMD GetTemperature, but AMD GPU wasn't found!");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
// TODO!
|
|
||||||
return 0;
|
std::ifstream file(tempFile);
|
||||||
|
std::string line;
|
||||||
|
std::getline(file, line);
|
||||||
|
return atoi(line.c_str()) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VRAM
|
struct VRAM
|
||||||
|
@ -65,12 +69,10 @@ namespace AMDGPU
|
||||||
std::ifstream file(vramTotalFile);
|
std::ifstream file(vramTotalFile);
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(file, line);
|
std::getline(file, line);
|
||||||
LOG("AMD GetVRAM(total): " << line);
|
|
||||||
mem.totalB = atoi(line.c_str());
|
mem.totalB = atoi(line.c_str());
|
||||||
|
|
||||||
file = std::ifstream(vramUsedFile);
|
file = std::ifstream(vramUsedFile);
|
||||||
std::getline(file, line);
|
std::getline(file, line);
|
||||||
LOG("AMD GetVRAM(total): " << line);
|
|
||||||
mem.usedB = atoi(line.c_str());
|
mem.usedB = atoi(line.c_str());
|
||||||
|
|
||||||
return mem;
|
return mem;
|
||||||
|
|
Loading…
Reference in a new issue