aboutsummaryrefslogtreecommitdiff
path: root/src/xnvctrl.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-03-17 17:17:14 +0100
committerdec05eba <dec05eba@protonmail.com>2023-03-17 17:17:14 +0100
commit93cb6593a642018e3373fb7099e1c0687b367176 (patch)
tree63d24dc3a9a03e71857ef793929f6000f75cc3db /src/xnvctrl.c
parent8cbdb596ebf79587a432ed40583630b6cd39ed88 (diff)
Add overclocking option -oc to workaround a NVIDIA driver bug (forcefully set to p2 state when using cuda)
Diffstat (limited to 'src/xnvctrl.c')
-rw-r--r--src/xnvctrl.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/xnvctrl.c b/src/xnvctrl.c
new file mode 100644
index 0000000..94d48d2
--- /dev/null
+++ b/src/xnvctrl.c
@@ -0,0 +1,44 @@
+#include "../include/xnvctrl.h"
+#include "../include/library_loader.h"
+#include <string.h>
+
+bool gsr_xnvctrl_load(gsr_xnvctrl *self, Display *display) {
+ memset(self, 0, sizeof(gsr_xnvctrl));
+ self->display = display;
+
+ dlerror(); /* clear */
+ void *lib = dlopen("libXNVCtrl.so.0", RTLD_LAZY);
+ if(!lib) {
+ fprintf(stderr, "gsr error: gsr_xnvctrl_load failed: failed to load libXNVCtrl.so.0, error: %s\n", dlerror());
+ return false;
+ }
+
+ dlsym_assign required_dlsym[] = {
+ { (void**)&self->XNVCTRLQueryExtension, "XNVCTRLQueryExtension" },
+ { (void**)&self->XNVCTRLSetTargetAttributeAndGetStatus, "XNVCTRLSetTargetAttributeAndGetStatus" },
+ { (void**)&self->XNVCTRLQueryValidTargetAttributeValues, "XNVCTRLQueryValidTargetAttributeValues" },
+ { (void**)&self->XNVCTRLQueryTargetStringAttribute, "XNVCTRLQueryTargetStringAttribute" },
+
+ { NULL, NULL }
+ };
+
+ if(!dlsym_load_list(lib, required_dlsym)) {
+ fprintf(stderr, "gsr error: gsr_xnvctrl_load failed: missing required symbols in libXNVCtrl.so.0\n");
+ goto fail;
+ }
+
+ self->library = lib;
+ return true;
+
+ fail:
+ dlclose(lib);
+ memset(self, 0, sizeof(gsr_xnvctrl));
+ return false;
+}
+
+void gsr_xnvctrl_unload(gsr_xnvctrl *self) {
+ if(self->library) {
+ dlclose(self->library);
+ memset(self, 0, sizeof(gsr_xnvctrl));
+ }
+}