update for xtx

This commit is contained in:
Carl Philipp Klemm 2025-12-20 11:16:49 +01:00
parent 1b85de18fe
commit ddcbeb1618

15
main.c
View file

@ -14,6 +14,7 @@ pid_t child_pid;
const char* drm_sysfs_path = "/sys/class/drm";
const char* rx6800xt_id = "fd4107589d5b1bb0\n";
const char* rx7900xtx_id = "86308d5dff4ce29e\n";
const char* auto_str = "auto\n";
const char* manual_str = "manual\n";
@ -23,7 +24,7 @@ void sig_handler(int sig)
kill(child_pid, sig);
}
int find_gpu(const char* id)
int find_gpu(const char* gpuid)
{
char path[255];
int i;
@ -40,7 +41,7 @@ int find_gpu(const char* id)
read(id_fd, id, sizeof(id)-1);
close(id_fd);
if(strcmp(id, rx6800xt_id) == 0)
if(strcmp(id, gpuid) == 0)
{
snprintf(path, sizeof(path), "%s/card%i/device/power_dpm_force_performance_level", drm_sysfs_path, i);
int fd = open(path, O_RDONLY);
@ -48,6 +49,7 @@ int find_gpu(const char* id)
}
}
}
printf("Unable to find gpu with id: %s\n", gpuid);
return -1;
}
@ -89,14 +91,19 @@ bool set_gpu_mode(const char* level, const char* mode, int card)
bool enable_vr_mode()
{
int card = find_gpu(rx6800xt_id);
int card = find_gpu(rx7900xtx_id);
if(card < 0)
return false;
return set_gpu_mode(manual_str, "4\n", card);
}
void disable_vr_mode()
{
int card = find_gpu(rx6800xt_id);
int card = find_gpu(rx7900xtx_id);
if(card < 0)
return;
set_gpu_mode(auto_str, "0\n", card);
}