Add Linux support for NVIDIA Founders Edition GPU Illumination Control
This commit is contained in:
parent
d778d470b1
commit
27128373e2
10 changed files with 52 additions and 27 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| NVIDIAIlluminationControllerDetect_Windows.cpp |
|
||||
| NVIDIAIlluminationControllerDetect_Windows_Linux.cpp |
|
||||
| |
|
||||
| Detector for NVIDIA Illumination GPU |
|
||||
| |
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
#include "Detector.h"
|
||||
#include "LogManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_NVIDIAIllumination_Windows.h"
|
||||
#include "RGBController_NVIDIAIllumination_Windows_Linux.h"
|
||||
#include "pci_ids.h"
|
||||
|
||||
enum
|
||||
|
|
@ -32,7 +32,7 @@ typedef struct
|
|||
int gpu_rgb_version;
|
||||
bool treats_rgbw_as_rgb;
|
||||
const char * name;
|
||||
} gpu_pci_device;
|
||||
} nv_gpu_pci_device;
|
||||
|
||||
|
||||
#define GPU_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
|
@ -44,7 +44,7 @@ typedef struct
|
|||
#define TREATS_RGBW_AS_RGB true
|
||||
#define TREATS_RGBW_AS_RGBW false
|
||||
|
||||
static const gpu_pci_device device_list[] =
|
||||
static const nv_gpu_pci_device device_list[] =
|
||||
{
|
||||
{NVIDIA_VEN, NVIDIA_RTX2070S_DEV, NVIDIA_VEN, NVIDIA_RTX2070_FE_SUPER_SUB_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGBW, "NVIDIA RTX 2070 SUPER FE" },
|
||||
{NVIDIA_VEN, NVIDIA_RTX2080_A_DEV, NVIDIA_VEN, NVIDIA_RTX2080_FE_SUB_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGBW, "NVIDIA RTX 2080 FE" },
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| NVIDIAIlluminationV1Controller_Windows.cpp |
|
||||
| NVIDIAIlluminationV1Controller_Windows_Linux.cpp |
|
||||
| |
|
||||
| Driver for NVIDIA Illumination V1 GPU |
|
||||
| |
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "NVIDIAIlluminationV1Controller_Windows.h"
|
||||
#include "NVIDIAIlluminationV1Controller_Windows_Linux.h"
|
||||
|
||||
NVIDIAIlluminationV1Controller::NVIDIAIlluminationV1Controller(nvapi_accessor* nvapi_ptr, bool treats_rgbw_as_rgb)
|
||||
{
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| NVIDIAIlluminationV1Controller_Windows.h |
|
||||
| NVIDIAIlluminationV1Controller_Windows_Linux.h |
|
||||
| |
|
||||
| Driver for NVIDIA Illumination V1 GPU |
|
||||
| |
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "nvapi_accessor_Windows.h"
|
||||
#include "nvapi_accessor_Windows_Linux.h"
|
||||
#include "RGBController.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| RGBController_NVIDIAIllumination.cpp |
|
||||
| RGBController_NVIDIAIllumination_Windows_Linux.cpp |
|
||||
| |
|
||||
| RGBController for NVIDIA Illumination GPU |
|
||||
| |
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <array>
|
||||
#include "RGBController_NVIDIAIllumination_Windows.h"
|
||||
#include "RGBController_NVIDIAIllumination_Windows_Linux.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name NVIDIA Illumination
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| RGBController_NVIDIAIllumination.h |
|
||||
| RGBController_NVIDIAIllumination_Windows_Linux.h |
|
||||
| |
|
||||
| RGBController for NVIDIA Illumination GPU |
|
||||
| |
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <map>
|
||||
#include "RGBController.h"
|
||||
#include "NVIDIAIlluminationV1Controller_Windows.h"
|
||||
#include "NVIDIAIlluminationV1Controller_Windows_Linux.h"
|
||||
|
||||
#define NVIDIA_FOUNDERS_V1_CONTROLLER_NAME "NVIDIA_FOUNDERS_V1"
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| nvapi_accessor_Windows.cpp |
|
||||
| nvapi_accessor_Windows_Linux.cpp |
|
||||
| |
|
||||
| NVAPI accessor for NVIDIA NVAPI illumination API |
|
||||
| |
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include "nvapi_accessor_Windows.h"
|
||||
#include "nvapi_accessor_Windows_Linux.h"
|
||||
|
||||
nvapi_accessor::nvapi_accessor(NV_PHYSICAL_GPU_HANDLE handle)
|
||||
{
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| nvapi_accessor_Windows.h |
|
||||
| nvapi_accessor_Windows_Linux.h |
|
||||
| |
|
||||
| NVAPI accessor for NVIDIA NVAPI illumination API |
|
||||
| |
|
||||
|
|
@ -479,10 +479,12 @@ contains(QMAKE_PLATFORM, linux) {
|
|||
HEADERS += $$CONTROLLER_H_LINUX
|
||||
|
||||
HEADERS += \
|
||||
dependencies/NVFC/nvapi.h \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
AutoStart/AutoStart-Linux.h \
|
||||
|
||||
INCLUDEPATH += \
|
||||
dependencies/NVFC \
|
||||
/usr/include/mbedtls2/ \
|
||||
|
||||
LIBS += \
|
||||
|
|
@ -528,6 +530,7 @@ contains(QMAKE_PLATFORM, linux) {
|
|||
|
||||
SOURCES += \
|
||||
dependencies/hueplusplus-1.1.0/src/LinHttpHandler.cpp \
|
||||
dependencies/NVFC/nvapi.cpp \
|
||||
i2c_smbus/i2c_smbus_linux.cpp \
|
||||
scsiapi/scsiapi_linux.c \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
|
|
|
|||
38
dependencies/NVFC/nvapi.cpp
vendored
38
dependencies/NVFC/nvapi.cpp
vendored
|
|
@ -1,7 +1,14 @@
|
|||
#define _WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#ifdef _WIN32
|
||||
#define _WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#elif __linux__
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include "nvapi.h"
|
||||
#include <string.h>
|
||||
|
||||
typedef void * (*nvapi_QueryInterface_t)(int);
|
||||
|
||||
// Constructors for NvAPI structures that just zero the memory and set the right version
|
||||
NV_DELTA_ENTRY::NV_DELTA_ENTRY()
|
||||
|
|
@ -248,7 +255,7 @@ static NV_STATUS(*pNvAPI_GPU_ClientIllumZonesSetControl)(
|
|||
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
|
||||
NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* pIllumZonesControl);
|
||||
|
||||
static bool QueryInterfaceOpaque(FARPROC query_interface, NV_U32 id, void **result)
|
||||
static bool QueryInterfaceOpaque(nvapi_QueryInterface_t query_interface, NV_U32 id, void **result)
|
||||
{
|
||||
void *address = ((void *(*)(NV_U32))query_interface)(id);
|
||||
if (address) {
|
||||
|
|
@ -259,7 +266,7 @@ static bool QueryInterfaceOpaque(FARPROC query_interface, NV_U32 id, void **resu
|
|||
}
|
||||
|
||||
template<typename F>
|
||||
static void QueryInterfaceCast(FARPROC query_interface, NV_U32 id, const char *function_name, F &function_pointer)
|
||||
static void QueryInterfaceCast(nvapi_QueryInterface_t query_interface, NV_U32 id, const char *function_name, F &function_pointer)
|
||||
{
|
||||
const bool result = QueryInterfaceOpaque(query_interface, id, (void **)&function_pointer);
|
||||
////Log::write("%s querying interface '0x%08x' '%s'", result ? "success" : "failure", id, function_name);
|
||||
|
|
@ -268,7 +275,7 @@ static void QueryInterfaceCast(FARPROC query_interface, NV_U32 id, const char *f
|
|||
#define QueryInterface(query_interface, id, function) \
|
||||
QueryInterfaceCast((query_interface), (id), #function, p ## function)
|
||||
|
||||
static void QueryInterfaces(FARPROC query_interface)
|
||||
static void QueryInterfaces(nvapi_QueryInterface_t query_interface)
|
||||
{
|
||||
//Log::write("querying interfaces with '0x%p'", query_interface);
|
||||
|
||||
|
|
@ -308,20 +315,35 @@ static void QueryInterfaces(FARPROC query_interface)
|
|||
NV_STATUS NvAPI_Initialize()
|
||||
{
|
||||
if (!pNvAPI_Initialize) {
|
||||
#ifdef _WIN32
|
||||
const char *name = sizeof(void*) == 4 ? "nvapi.dll" : "nvapi64.dll";
|
||||
HMODULE nvapi = LoadLibraryA(name);
|
||||
if (!nvapi) {
|
||||
//Log::write("failed to load '%s'", name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Log::write("loaded '%s' '0x%p'", name, nvapi);
|
||||
|
||||
FARPROC query_interface = GetProcAddress(nvapi, "nvapi_QueryInterface");
|
||||
nvapi_QueryInterface_t query_interface = (nvapi_QueryInterface_t) GetProcAddress(nvapi, "nvapi_QueryInterface");
|
||||
if (!query_interface) {
|
||||
//Log::write("failed to find 'nvapi_QueryInterface'");
|
||||
return -1;
|
||||
}
|
||||
#elif __linux__
|
||||
void* nvapi;
|
||||
if (!nvapi) nvapi = dlopen("libnvidia-api.so.1", RTLD_LAZY);
|
||||
if (!nvapi) nvapi = dlopen("libnvidia-api.so", RTLD_LAZY);
|
||||
if (!nvapi) {
|
||||
// NVIDIA Driver is not installed
|
||||
//Log::write("failed to load libnvidia-api.so, NVIDIA Driver is not installed");
|
||||
return -1;
|
||||
}
|
||||
nvapi_QueryInterface_t query_interface = (nvapi_QueryInterface_t) dlsym(nvapi, "nvapi_QueryInterface");
|
||||
if (!query_interface) {
|
||||
// NVIDIA Driver is probably not up to date, requires at least driver version 525
|
||||
//Log::write("failed to load QueryInterface from libnvidia-api.so, NVIDIA Driver is not up to date");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
QueryInterfaces(query_interface);
|
||||
}
|
||||
|
|
|
|||
8
dependencies/NVFC/nvapi.h
vendored
8
dependencies/NVFC/nvapi.h
vendored
|
|
@ -1024,12 +1024,12 @@ NV_STATUS NvAPI_I2CReadEx(
|
|||
|
||||
// Interface: 73C01D58
|
||||
NV_STATUS NvAPI_GPU_ClientIllumZonesGetControl(
|
||||
__in NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
|
||||
__inout NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* pIllumZonesControl);
|
||||
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
|
||||
NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* pIllumZonesControl);
|
||||
|
||||
// Interface: 57024C62
|
||||
NV_STATUS NvAPI_GPU_ClientIllumZonesSetControl(
|
||||
__in NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
|
||||
__inout NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* pIllumZonesControl);
|
||||
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
|
||||
NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* pIllumZonesControl);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue