buitching
This commit is contained in:
14
src/gpu.c
14
src/gpu.c
@@ -6,12 +6,8 @@
|
||||
#include "log.h"
|
||||
#include "utils.h"
|
||||
|
||||
constexpr char rel_metrics_path[] = "/../../gpu_metrics"; // gpu_metrics path relative to hwmon path
|
||||
constexpr uint16_t max_metrics_length = 512; // length of the metrics buffer
|
||||
|
||||
void fill_missing_metrics(struct gpu_sensors_t *g);
|
||||
void update_from_fs(struct gpu_sensors_t *g);
|
||||
void update_from_metrics(struct gpu_sensors_t *g);
|
||||
static constexpr char rel_metrics_path[] = "/../../gpu_metrics"; // gpu_metrics path relative to hwmon path
|
||||
static constexpr uint16_t max_metrics_length = 512; // length of the metrics buffer
|
||||
|
||||
void gpu_detect(struct gpu_sensors_t *t, const char *pci) {
|
||||
snprintf(t->hwmon, sizeof(t->hwmon), "/sys/bus/pci/devices/%s/hwmon", pci);
|
||||
@@ -32,7 +28,7 @@ void gpu_detect(struct gpu_sensors_t *t, const char *pci) {
|
||||
}
|
||||
|
||||
/* some metrics are missing in gpu_metrics, we always fill them from fs, unused metrics are commented out */
|
||||
void fill_missing_metrics(struct gpu_sensors_t *g) {
|
||||
static void fill_missing_metrics(struct gpu_sensors_t *g) {
|
||||
char buf[32];
|
||||
fast_read_num_f(g->hwmon, "/in0_input", buf, &g->vcore, 1000);
|
||||
// g->fan_pwm = std::stoi(readFile(g->hwmon + "/pwm1", 4)) * 100 / 256;
|
||||
@@ -45,7 +41,7 @@ void fill_missing_metrics(struct gpu_sensors_t *g) {
|
||||
}
|
||||
|
||||
/* get sensors for pre-vega cards (rx480/580) */
|
||||
void update_from_fs(struct gpu_sensors_t *g) {
|
||||
static void update_from_fs(struct gpu_sensors_t *g) {
|
||||
char buf[32];
|
||||
fast_read_num_u16(g->hwmon, "/freq1_input", buf, &g->clock_core, 1000000);
|
||||
fast_read_num_u16(g->hwmon, "/freq2_input", buf, &g->clock_mem, 1000000);
|
||||
@@ -54,7 +50,7 @@ void update_from_fs(struct gpu_sensors_t *g) {
|
||||
fast_read_num_u8(g->hwmon, "/../../gpu_busy_percent", buf, &g->usage_core, 1);
|
||||
}
|
||||
|
||||
void update_from_metrics(struct gpu_sensors_t *g) {
|
||||
static void update_from_metrics(struct gpu_sensors_t *g) {
|
||||
char raw_metrics[max_metrics_length];
|
||||
|
||||
if (!read_file(g->hwmon, rel_metrics_path, raw_metrics, sizeof(raw_metrics)))
|
||||
|
||||
Reference in New Issue
Block a user