diff --git a/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationControllerDetect.cpp b/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationControllerDetect.cpp new file mode 100644 index 00000000..4866e9eb --- /dev/null +++ b/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationControllerDetect.cpp @@ -0,0 +1,111 @@ +/*----------------------------------------------*\ +| NVIDIAIlluminationControllerDetect.cpp | +| | +| Detect GPUS that are controlled by the direct | +| NVIDIA Illumination controller. | +| | +| Carter Miller (GingerRunner) 1/4/2022 | +\*----------------------------------------------*/ + +#include "Detector.h" + +#include "LogManager.h" +#include "RGBController.h" +#include "RGBController_NVIDIAIllumination.h" + +#include "pci_ids.h" +#include +#include +#include + +enum +{ + NVIDIA_ILLUMINATION_V1 +}; + +typedef struct +{ + int pci_vendor; + int pci_device; + int pci_subsystem_vendor; + int pci_subsystem_device; + int gpu_rgb_version; + bool treats_rgbw_as_rgb; + const char * name; +} gpu_pci_device; + + +#define GPU_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ])) + +/*-----------------------------------------------------------------------------------------------------*\ +| Certain devices seem to ignore the white value entirely, despite the zone being reported back by the | +| API as RGBW, so this boolean is passed at detection time via constructor inform the controller logic. | +\*-----------------------------------------------------------------------------------------------------*/ +#define TREATS_RGBW_AS_RGB true +#define TREATS_RGBW_AS_RGBW false + +static const 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 2070 SUPER FE" }, + {NVIDIA_VEN, NVIDIA_RTX3060TI_LHR_DEV, NVIDIA_VEN, PNY_RTX_3060TI_XLR8_REVEL_EPIC_X_SUB_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGB, "PNY 3060TI XLR8 REVEL EPIC-X"}, + {NVIDIA_VEN, NVIDIA_RTX3060TI_V1_LHR_DEV, NVIDIA_VEN, NVIDIA_RTX3060TI_V1_LHR_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGB, "NVIDIA 3060TI V1 LHR" }, + {NVIDIA_VEN, NVIDIA_RTX3060TI_LHR_DEV, NVIDIA_VEN, NVIDIA_RTX3060TI_LHR_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGBW, "NVIDIA 3060TI LHR" }, + {NVIDIA_VEN, NVIDIA_RTX3080_DEV, NVIDIA_VEN, NVIDIA_RTX3080_FE_SUB_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGBW, "NVIDIA 3080 FE" }, + {NVIDIA_VEN, NVIDIA_RTX3080TI_DEV, NVIDIA_VEN, NVIDIA_RTX3080TI_FE_SUB_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGBW, "NVIDIA 3080TI FE" }, + {NVIDIA_VEN, NVIDIA_RTX3090_DEV, NVIDIA_VEN, NVIDIA_RTX3090_FE_SUB_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGBW, "NVIDIA 3090 FE" }, + {NVIDIA_VEN, NVIDIA_RTX3090TI_DEV, NVIDIA_VEN, NVIDIA_RTX3090TI_FE_SUB_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGBW, "NVIDIA 3090TI FE" }, +}; + +bool DetectNVIDIAIllumGPUs() +{ + static NV_PHYSICAL_GPU_HANDLE gpu_handles[64]; + static NV_S32 gpu_count = 0; + NV_U32 device_id; + NV_U32 ext_device_id; + NV_STATUS res; + NV_U32 revision_id; + NV_U32 sub_system_id; + + NV_STATUS initialize = NvAPI_Initialize(); + + NvAPI_EnumPhysicalGPUs(gpu_handles, &gpu_count); + + for(NV_S32 gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) + { + res = NvAPI_GPU_GetPCIIdentifiers(gpu_handles[gpu_idx], &device_id, &sub_system_id, &revision_id, &ext_device_id); + if (res == 0) + { + uint16_t pci_device = device_id >> 16; + uint16_t pci_vendor = device_id & 0xffff; + uint16_t pci_subsystem_device = sub_system_id >> 16; + uint16_t pci_subsystem_vendor = sub_system_id & 0xffff; + for(unsigned int dev_idx = 0; dev_idx < GPU_NUM_DEVICES; dev_idx++) + { + if(pci_vendor == device_list[dev_idx].pci_vendor && + pci_device == device_list[dev_idx].pci_device && + pci_subsystem_vendor == device_list[dev_idx].pci_subsystem_vendor && + pci_subsystem_device == device_list[dev_idx].pci_subsystem_device) + { + LOG_DEBUG("[%s] NVidia NvAPI Illumination GPU found", device_list[dev_idx].name); + switch(device_list[dev_idx].gpu_rgb_version) + { + case NVIDIA_ILLUMINATION_V1: + { + NVIDIAIlluminationV1Controller* new_controller; + RGBController_NVIDIAIlluminationV1* new_rgbcontroller; + nvapi_accessor* new_nvapi = new nvapi_accessor(gpu_handles[gpu_idx]); + new_controller = new NVIDIAIlluminationV1Controller(new_nvapi, device_list[dev_idx].treats_rgbw_as_rgb); + new_rgbcontroller = new RGBController_NVIDIAIlluminationV1(new_controller); + new_rgbcontroller->name = device_list[dev_idx].name; + ResourceManager::get()->RegisterRGBController(new_rgbcontroller); + } + break; + } + } + } + } + } + return(true); +} + +REGISTER_I2C_BUS_DETECTOR(DetectNVIDIAIllumGPUs); diff --git a/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.cpp b/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.cpp new file mode 100644 index 00000000..7283b945 --- /dev/null +++ b/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.cpp @@ -0,0 +1,204 @@ +/*-----------------------------------------------*\ +| NVIDIAIlluminationV1Controller.cpp | +| | +| Driver for NVIDIA Illumination controlled GPUs | +| | +| Carter Miller (GingerRunner) 1/5/2022 | +\*-----------------------------------------------*/ + +#include "NVIDIAIlluminationV1Controller.h" + +NVIDIAIlluminationV1Controller::NVIDIAIlluminationV1Controller(nvapi_accessor* nvapi_ptr, bool treats_rgbw_as_rgb) +{ + nvapi = nvapi_ptr; + _treats_rgbw_as_rgb = treats_rgbw_as_rgb; +} + +NVIDIAIlluminationV1Controller::~NVIDIAIlluminationV1Controller() +{ +} + +void NVIDIAIlluminationV1Controller::checkNVAPIreturn() +{ + if (nvapi_return != NVAPI_OK) + { + LOG_DEBUG("NVAPI return code not NVAPI_OK: %d", nvapi_return); + } +} + +void NVIDIAIlluminationV1Controller::getControl() +{ + /*------------------------------------------------------------------------------------------------*\ + | This was previously memset(&zone_params, 0, sizeof(zone_params)) | + | But this kind of zero initialization is more up-to-date and safer in the event of non-primitive | + | data types | + \*------------------------------------------------------------------------------------------------*/ + zone_params = {}; + /*---------------------------------------------------------------------------------------------------*\ + | Hardcoded value found via sniffing, this may be different for other cards, once that is | + | found, may be best to simply if/else this based on the card detected or map it out in the detector | + | and then pass via constructor to here. | + \*---------------------------------------------------------------------------------------------------*/ + zone_params.version = 72012; + zone_params.bDefault = 0; + /*---------------------------------------------------------------------------------------------------*\ + | As far as I can tell, this pre-populates the zone type value, as well as the number of zones | + | able to be controlled, and their existing settings, very useful for extending this controller. | + \*---------------------------------------------------------------------------------------------------*/ + nvapi_return = nvapi->nvapi_zone_control(NVAPI_ZONE_GET_CONTROL, &zone_params); + checkNVAPIreturn(); +} + +void NVIDIAIlluminationV1Controller::setControl() +{ + nvapi_return = nvapi->nvapi_zone_control(NVAPI_ZONE_SET_CONTROL, &zone_params); + checkNVAPIreturn(); +} + +/*----------------------------------------------------------------------------------------------------*\ +| This function exists to check if RGB colors are all set to zero, and if so, to take the brightness | +| down to zero. This was done to comply with functionality in OpenRGB such as "Lights Off" which | +| sends RGB values of all zeroes, but doesn't seem to send a brightness of zero at this time (6/2022). | +\*----------------------------------------------------------------------------------------------------*/ +bool NVIDIAIlluminationV1Controller::allZero(std::array colors) +{ + return colors == all_zeros; +} + +void NVIDIAIlluminationV1Controller::setZoneRGBW(uint8_t zone, uint8_t red, uint8_t green, uint8_t blue, uint8_t white, uint8_t brightness) +{ + zone_params.zones[zone].data.rgbw.data.manualRGBW.rgbwParams.colorR = red; + zone_params.zones[zone].data.rgbw.data.manualRGBW.rgbwParams.colorG = green; + zone_params.zones[zone].data.rgbw.data.manualRGBW.rgbwParams.colorB = blue; + zone_params.zones[zone].data.rgbw.data.manualRGBW.rgbwParams.colorW = white; + zone_params.zones[zone].data.rgbw.data.manualRGBW.rgbwParams.brightnessPct = brightness; +} + +void NVIDIAIlluminationV1Controller::setZoneRGB(uint8_t zone, uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness) +{ + zone_params.zones[zone].data.rgb.data.manualRGB.rgbParams.colorR = red; + zone_params.zones[zone].data.rgb.data.manualRGB.rgbParams.colorG = green; + zone_params.zones[zone].data.rgb.data.manualRGB.rgbParams.colorB = blue; + zone_params.zones[zone].data.rgb.data.manualRGB.rgbParams.brightnessPct = brightness; +} + + +void NVIDIAIlluminationV1Controller::setZone(uint8_t zone, uint8_t mode, NVIDIAIllumination_Config zone_config) +{ + getControl(); + uint8_t red = RGBGetRValue(zone_config.colors[0]); + uint8_t green = RGBGetGValue(zone_config.colors[0]); + uint8_t blue = RGBGetBValue(zone_config.colors[0]); + uint8_t white = 0; + switch(mode) + { + case NVIDIA_ILLUMINATION_OFF: + zone_params.zones[zone].ctrlMode = NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB; + if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGB) + { + setZoneRGB(zone, 0, 0, 0, 0); + } + else if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGBW) + { + setZoneRGBW(zone, 0, 0, 0, 0, 0); + } + else if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_SINGLE_COLOR) + { + zone_params.zones[zone].data.singleColor.data.manualSingleColor.singleColorParams.brightnessPct = 0; + } + else if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED) + { + zone_params.zones[zone].data.colorFixed.data.manualColorFixed.colorFixedParams.brightnessPct = 0; + } + else if (zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED) + { + zone_params.zones[zone].data.colorFixed.data.manualColorFixed.colorFixedParams.brightnessPct = 0; + } + else if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED) + { + zone_params.zones[zone].data.colorFixed.data.manualColorFixed.colorFixedParams.brightnessPct = 0; + } + else if (zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED) + { + zone_params.zones[zone].data.colorFixed.data.manualColorFixed.colorFixedParams.brightnessPct = 0; + } + break; + case NVIDIA_ILLUMINATION_DIRECT: + zone_params.zones[zone].ctrlMode = NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB; + if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGB) + { + setZoneRGB(zone, red, green, blue, zone_config.brightness); + } + else if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGBW) + { + /*----------------------------------------------------------------------------------------------------*\ + | Certain devices seem to ignore the white value entirely, despite the zone being reported back by the | + | API as RGBW, as such, this if statement was added to conduct a different course of action based | + | on definitions placed in the controller page | + \*----------------------------------------------------------------------------------------------------*/ + if(!_treats_rgbw_as_rgb) + { + uint8_t min_rgb_value = 0xFF; + uint8_t max_rgb_value = 0; + min_rgb_value = ((red < 0xFF) ? red : min_rgb_value); + min_rgb_value = ((green < min_rgb_value) ? green : min_rgb_value); + min_rgb_value = ((blue < min_rgb_value) ? blue : min_rgb_value); + max_rgb_value = ((red > 0) ? red : max_rgb_value); + max_rgb_value = ((green > max_rgb_value) ? green : max_rgb_value); + max_rgb_value = ((blue > max_rgb_value) ? blue : max_rgb_value); + /*---------------------------------------------------------------------------------------------------*\ + | If difference between the highest and lowest RGB values is 10 or lower, set the white value only, | + | zero out the rest, this logic was found via tedious examination | + \*---------------------------------------------------------------------------------------------------*/ + if (max_rgb_value - min_rgb_value <= 10) + { + red = 0; + green = 0; + blue = 0; + white = (max_rgb_value + min_rgb_value)/2; + } + } + setZoneRGBW(zone, red, green, blue, white, zone_config.brightness); + } + else if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_SINGLE_COLOR) + { + zone_params.zones[zone].data.singleColor.data.manualSingleColor.singleColorParams.brightnessPct = allZero({red, green, blue, white}) ? 0 : zone_config.brightness; + } + else if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED) + { + zone_params.zones[zone].data.colorFixed.data.manualColorFixed.colorFixedParams.brightnessPct = allZero({red, green, blue, white}) ? 0 : zone_config.brightness; + } + else if (zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED) + { + zone_params.zones[zone].data.colorFixed.data.manualColorFixed.colorFixedParams.brightnessPct = allZero({red, green, blue, white}) ? 0 : zone_config.brightness; + } + else if(zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED) + { + zone_params.zones[zone].data.colorFixed.data.manualColorFixed.colorFixedParams.brightnessPct = allZero({red, green, blue, white}) ? 0 : zone_config.brightness; + } + else if (zone_params.zones[zone].type == NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED) + { + zone_params.zones[zone].data.colorFixed.data.manualColorFixed.colorFixedParams.brightnessPct = allZero({red, green, blue, white}) ? 0 : zone_config.brightness; + } + break; + } + setControl(); +} + +int NVIDIAIlluminationV1Controller::getZoneColor(uint8_t zone_index) +{ + return ToRGBColor(zone_params.zones[zone_index].data.rgb.data.manualRGB.rgbParams.colorR, + zone_params.zones[zone_index].data.rgb.data.manualRGB.rgbParams.colorG, + zone_params.zones[zone_index].data.rgb.data.manualRGB.rgbParams.colorB); +} + +std::vector NVIDIAIlluminationV1Controller::getInfo() +{ + std::vector zone_types; + getControl(); + for(unsigned int i = 0; i < zone_params.numIllumZonesControl; i++) + { + zone_types.push_back(zone_params.zones[i].type); + } + return zone_types; +} diff --git a/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.h b/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.h new file mode 100644 index 00000000..3ea81e46 --- /dev/null +++ b/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.h @@ -0,0 +1,60 @@ +/*-----------------------------------------*\ +| NVIDIAIlluminationV1Controller.h | +| | +| Definitions and types for direct NVIDIA | +| Illumination-based NVIDIA GPUs' RGB | +| controller | +| | +| Carter Miller (GingerRunner) 1/4/2022 | +\*-----------------------------------------*/ + + +#include +#include +#include +#include "nvapi_accessor.h" +#include "RGBController.h" +#include "LogManager.h" + +#pragma once + +#define NVIDIA_ILLUMINATION_V1_CONTROLLER_NAME "NVIDIA_ILLUMINATION_V1" +#define NVAPI_OK 0 + +struct NVIDIAIllumination_Config +{ + uint8_t brightness; + RGBColor colors[7]; +}; + +enum +{ + NVIDIA_ILLUMINATION_OFF = 0, + NVIDIA_ILLUMINATION_DIRECT = 1 +}; + +class NVIDIAIlluminationV1Controller +{ + public: + NVIDIAIlluminationV1Controller(nvapi_accessor* nvapi_ptr, bool treats_rgbw_as_rgb); + ~NVIDIAIlluminationV1Controller(); + + void getControl(); + void setControl(); + bool allZero(std::array colors); + void setZoneRGBW(uint8_t zone, uint8_t red, uint8_t green, uint8_t blue, uint8_t white, uint8_t brightness); + void setZoneRGB(uint8_t zone, uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness); + void setZone(uint8_t zone, uint8_t mode, NVIDIAIllumination_Config zone_config); + int getZoneColor(uint8_t zone_index); + std::vector getInfo(); + + private: + void checkNVAPIreturn(); + + nvapi_accessor* nvapi; + bool _treats_rgbw_as_rgb; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS zone_params; + NV_STATUS nvapi_return = 0; + const std::array all_zeros = {0, 0, 0, 0}; + +}; diff --git a/Controllers/NVIDIAIlluminationController/RGBController_NVIDIAIllumination.cpp b/Controllers/NVIDIAIlluminationController/RGBController_NVIDIAIllumination.cpp new file mode 100644 index 00000000..0aad9b23 --- /dev/null +++ b/Controllers/NVIDIAIlluminationController/RGBController_NVIDIAIllumination.cpp @@ -0,0 +1,210 @@ +/*--------------------------------------------*\ +| RGBController_NVIDIAIllumination.cpp | +| | +| Generic RGB Interface for OpenRGB direct | +| NVIDIA Illumination controller NVIDIA GPUs. | +| Note that this works for Windows only. | +| | +| Carter Miller (GingerRunner) 1/4/2022 | +\*--------------------------------------------*/ + +/**------------------------------------------------------------------*\ + @name NVIDIA Illumination + @category GPU + @type PCI + @save :x: + @direct :white_check_mark: + @effects :x: + @detectors DetectNVIDIAIlluminationGPUControllers + @comment Tested on various 30 series GPUs and a Founders Edition 2070 Super + If you want to see if your card should also use this controller, download the DLLs from the release of [this](https://gitlab.com/OpenRGBDevelopers/NvAPISpy). + + Perform the global replacement technique, which is specified in the README of NvAPI spy. Once this is complete, use an RGB program of your choice and make some basic + lighting changes. + + Check the C:\NvAPISpy\ folder and see if the logs created are filled with calls like this: + ``` + NvAPI_GPU_ClientIllumZonesGetControl: version: 72012 numIllumZones: 2 bDefault: 0 rsvdField: 0 + ZoneIdx: 0 ---------------------------------------- + **ZoneType: RGBW ControlMode: MANUAL + **DATA_RGBW:: Red: 255 Green: 0 Blue: 0 White: 0 Brightness%: 36 + ZoneIdx: 1 ---------------------------------------- + **ZoneType: SINGLE_COLOR ControlMode: MANUAL + **DATA_SINGLE_COLOR:: Brightness% 100 + NvAPI_GPU_ClientIllumZonesSetControl: version: 72012 numIllumZones: 2 bDefault: 0 rsvdField: 0 + ZoneIdx: 0 ---------------------------------------- + **ZoneType: RGBW ControlMode: MANUAL + **DATA_RGBW:: Red: 255 Green: 0 Blue: 0 White: 0 Brightness%: 36 + ZoneIdx: 1 ---------------------------------------- + **ZoneType: SINGLE_COLOR ControlMode: MANUAL + **DATA_SINGLE_COLOR:: Brightness% 44 + ``` + If you see Get/Set Calls above for zone control, please create a [new device issue](https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/new?issuable_template=New%20Device#) + and attach the relevant details to request support for your device (try various modes in each color, especially white and shades around it, since some cards treat RGBW as + standard RGB). +\*-------------------------------------------------------------------*/ + + +/**------------------------------------------------------------------*\ + @name NVIDIA Illumination + @category GPU + @type PCI + @save :x: + @direct :white_check_mark: + @effects :x: + @detectors DetectNVIDIAIlluminationGPUControllers + @comment Tested on various 30 series GPUs and a Founders Edition 2070 Super + If you want to see if your card should also use this controller, download the DLLs from the release of [this](https://gitlab.com/OpenRGBDevelopers/NvAPISpy). + + Perform the global replacement technique, which is specified in the README of NvAPI spy. Once this is complete, use an RGB program of your choice and make some basic + lighting changes. + + Check the C:\NvAPISpy\ folder and see if the logs created are filled with calls like this: + ``` + NvAPI_GPU_ClientIllumZonesGetControl: version: 72012 numIllumZones: 2 bDefault: 0 rsvdField: 0 + ZoneIdx: 0 ---------------------------------------- + **ZoneType: RGBW ControlMode: MANUAL + **DATA_RGBW:: Red: 255 Green: 0 Blue: 0 White: 0 Brightness%: 36 + ZoneIdx: 1 ---------------------------------------- + **ZoneType: SINGLE_COLOR ControlMode: MANUAL + **DATA_SINGLE_COLOR:: Brightness% 100 + NvAPI_GPU_ClientIllumZonesSetControl: version: 72012 numIllumZones: 2 bDefault: 0 rsvdField: 0 + ZoneIdx: 0 ---------------------------------------- + **ZoneType: RGBW ControlMode: MANUAL + **DATA_RGBW:: Red: 255 Green: 0 Blue: 0 White: 0 Brightness%: 36 + ZoneIdx: 1 ---------------------------------------- + **ZoneType: SINGLE_COLOR ControlMode: MANUAL + **DATA_SINGLE_COLOR:: Brightness% 44 + ``` + If you see Get/Set Calls above for zone control, please create a [new device issue](https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/new?issuable_template=New%20Device#) + and attach the relevant details to request support for your device (try various modes in each color, especially white and shades around it, since some cards treat RGBW as + standard RGB). +\*-------------------------------------------------------------------*/ + + +#include "RGBController_NVIDIAIllumination.h" +#include "NVIDIAIlluminationV1Controller.h" +#include + +RGBController_NVIDIAIlluminationV1::RGBController_NVIDIAIlluminationV1(NVIDIAIlluminationV1Controller* controller_ptr) +{ + controller = controller_ptr; + + name = "NVIDIA Illumination GPU"; + vendor = "NVIDIA"; + description = "NVIDIA Illumination RGB GPU Device"; + + type = DEVICE_TYPE_GPU; + + mode Off; + Off.name = "Off"; + Off.value = NVIDIA_ILLUMINATION_OFF; + Off.color_mode = MODE_COLORS_NONE; + modes.push_back(Off); + + mode Static; + Static.name = "Direct"; + Static.value = NVIDIA_ILLUMINATION_DIRECT; + Static.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR; + Static.color_mode = MODE_COLORS_PER_LED; + Static.colors_min = 1; + Static.colors_max = 1; + Static.brightness_min = 0; + Static.brightness = 100; + Static.brightness_max = 100; + modes.push_back(Static); + + SetupZones(); + + for(unsigned int i = 0; i < zones.size(); i++) + { + zones[i].colors[0] = controller->getZoneColor(i); + } +} + +RGBController_NVIDIAIlluminationV1::~RGBController_NVIDIAIlluminationV1() +{ + delete controller; +} + +void RGBController_NVIDIAIlluminationV1::UpdateSingleLED(int) +{ + DeviceUpdateLEDs(); +} + +void RGBController_NVIDIAIlluminationV1::SetupZones() +{ + /*--------------------------------------------------------------------------*\ + | Use the NvAPI to gather existing zones on the card and their capabilities, | + | populate available zones accordingly. | + \*--------------------------------------------------------------------------*/ + zoneTypes = controller->getInfo(); + nvidia_illum_zone_names[NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGB] = "RGB"; + nvidia_illum_zone_names[NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGBW] = "RGBW"; + nvidia_illum_zone_names[NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED] = "FIXED COLOR"; + nvidia_illum_zone_names[NV_GPU_CLIENT_ILLUM_ZONE_TYPE_SINGLE_COLOR] = "SINGLE COLOR"; + for(uint8_t zone_idx = 0; zone_idx < zoneTypes.size(); zone_idx++) + { + zone* new_zone = new zone(); + led* new_led = new led(); + + new_zone->name = std::to_string(zone_idx) + " - " + (std::string)nvidia_illum_zone_names[zoneTypes[zone_idx]]; + new_zone->type = ZONE_TYPE_SINGLE; + new_zone->leds_min = 1; + new_zone->leds_max = 1; + new_zone->leds_count = 1; + new_zone->matrix_map = NULL; + new_led->name = "Entire Zone"; + leds.push_back(*new_led); + zones.push_back(*new_zone); + zoneIndexMap.push_back(zone_idx); + } + SetupColors(); + +} + +void RGBController_NVIDIAIlluminationV1::DeviceUpdateLEDs() +{ + NVIDIAIllumination_Config nv_zone_config; + for(uint8_t zone_idx = 0; zone_idx < zoneIndexMap.size(); zone_idx++) + { + nv_zone_config.colors[0] = colors[zone_idx]; + nv_zone_config.brightness = modes[active_mode].brightness; + controller->setZone(zone_idx, modes[active_mode].value, nv_zone_config); + } +} + +void RGBController_NVIDIAIlluminationV1::UpdateZoneLEDs(int zone) +{ + NVIDIAIllumination_Config nv_zone_config; + nv_zone_config.colors[0] = colors[zone]; + nv_zone_config.brightness = modes[active_mode].brightness; + controller->setZone(zone, modes[active_mode].value, nv_zone_config); +} + +uint8_t RGBController_NVIDIAIlluminationV1::getModeIndex(uint8_t mode_value) +{ + for(uint8_t mode_index = 0; mode_index < modes.size(); mode_index++) + { + if(modes[mode_index].value == mode_value) + { + return mode_index; + } + } + return 0; +} + +void RGBController_NVIDIAIlluminationV1::SetCustomMode() +{ + active_mode = getModeIndex(NVIDIA_ILLUMINATION_DIRECT); +} + +void RGBController_NVIDIAIlluminationV1::DeviceUpdateMode() +{ + DeviceUpdateLEDs(); +} + +void RGBController_NVIDIAIlluminationV1::ResizeZone(int zone, int new_size) +{ + +} diff --git a/Controllers/NVIDIAIlluminationController/RGBController_NVIDIAIllumination.h b/Controllers/NVIDIAIlluminationController/RGBController_NVIDIAIllumination.h new file mode 100644 index 00000000..0b92cb53 --- /dev/null +++ b/Controllers/NVIDIAIlluminationController/RGBController_NVIDIAIllumination.h @@ -0,0 +1,45 @@ +/*-----------------------------------------*\ +| RGBController_NVIDIAIllumination.h | +| | +| NVIDIA Illumination Generic RGB Interface| +| for OpenRGB | +| | +| Carter Miller (GingerRunner) 1/4/2022 | +\*-----------------------------------------*/ + + +#pragma once + +#include "RGBController.h" +#include "NVIDIAIlluminationV1Controller.h" +#include + +#define NVIDIA_FOUNDERS_V1_CONTROLLER_NAME "NVIDIA_FOUNDERS_V1" + +class RGBController_NVIDIAIlluminationV1 : public RGBController +{ + public: + RGBController_NVIDIAIlluminationV1(NVIDIAIlluminationV1Controller* nvidia_founders_ptr); + ~RGBController_NVIDIAIlluminationV1(); + + void UpdateSingleLED(int led); + + void SetupZones(); + + void DeviceUpdateLEDs(); + + void UpdateZoneLEDs(int); + + void SetCustomMode(); + + void DeviceUpdateMode(); + + void ResizeZone(int, int); + + private: + uint8_t getModeIndex(uint8_t mode_value); + NVIDIAIlluminationV1Controller* controller; + std::vector zoneIndexMap; + std::vector zoneTypes; + std::map nvidia_illum_zone_names; +}; \ No newline at end of file diff --git a/Controllers/NVIDIAIlluminationController/nvapi_accessor.cpp b/Controllers/NVIDIAIlluminationController/nvapi_accessor.cpp new file mode 100644 index 00000000..cd2152bf --- /dev/null +++ b/Controllers/NVIDIAIlluminationController/nvapi_accessor.cpp @@ -0,0 +1,38 @@ +/*-----------------------------------------*\ +| nvapi_accessor.cpp | +| | +| Definitions and for Nvidia NvAPI | +| direct access class | +| | +| Carter Miller (GingerRunner) 6/20/2022 | +\*-----------------------------------------*/ + +#include "nvapi_accessor.h" +#include +#include + +nvapi_accessor::nvapi_accessor(NV_PHYSICAL_GPU_HANDLE handle) +{ + this->handle = handle; +} + +NV_STATUS nvapi_accessor::nvapi_zone_control(char nvapi_call, NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* zone_control_struct) +{ + NV_STATUS ret = -1; + + if(nvapi_call == NVAPI_ZONE_SET_CONTROL) + { + ret = NvAPI_GPU_ClientIllumZonesSetControl(handle, zone_control_struct); + } + else if(nvapi_call == NVAPI_ZONE_GET_CONTROL) + { + ret = NvAPI_GPU_ClientIllumZonesGetControl(handle, zone_control_struct); + } + /*----------------------------------------------------------------------------------*\ + | Based off experimentation, the NvAPI doesn't like to be spammed calls | + | or else it just ignores them, this applies to both get/set control (GingerRunner) | + \*----------------------------------------------------------------------------------*/ + std::this_thread::sleep_for(std::chrono::milliseconds(NVAPI_CONTROL_BUFFER_TIME_MS)); + + return(ret); +} diff --git a/Controllers/NVIDIAIlluminationController/nvapi_accessor.h b/Controllers/NVIDIAIlluminationController/nvapi_accessor.h new file mode 100644 index 00000000..57f6c713 --- /dev/null +++ b/Controllers/NVIDIAIlluminationController/nvapi_accessor.h @@ -0,0 +1,25 @@ +/*-----------------------------------------*\ +| nvapi_accessor.h | +| | +| Definitions and types for Nvidia NvAPI | +| direct access class | +| | +| Carter Miller (GingerRunner) 6/20/2022 | +\*-----------------------------------------*/ + +#include "nvapi.h" + +// NVAPI Direct Calls +#define NVAPI_ZONE_GET_CONTROL 0 +#define NVAPI_ZONE_SET_CONTROL 1 +#define NVAPI_CONTROL_BUFFER_TIME_MS 30 + +class nvapi_accessor +{ +public: + nvapi_accessor(NV_PHYSICAL_GPU_HANDLE handle); + NV_STATUS nvapi_zone_control(char nvapi_call, NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* zone_control_struct); + +private: + NV_PHYSICAL_GPU_HANDLE handle; +}; diff --git a/Controllers/PNYGPUController/PNYGPUControllerDetect.cpp b/Controllers/PNYGPUController/PNYGPUControllerDetect.cpp index a73d0804..9d19de85 100644 --- a/Controllers/PNYGPUController/PNYGPUControllerDetect.cpp +++ b/Controllers/PNYGPUController/PNYGPUControllerDetect.cpp @@ -39,7 +39,7 @@ REGISTER_I2C_PCI_DETECTOR("PNY XLR8 Revel EPIC-X RTX 3090", DetectPNYGPUCont REGISTER_I2C_PCI_DETECTOR("Palit 3060", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3060_DEV, PALIT_SUB_VEN, PALIT_RTX3060_SUB_DEV, 0x49); REGISTER_I2C_PCI_DETECTOR("Palit 3060 LHR", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3060_LHR_DEV, PALIT_SUB_VEN, PALIT_RTX3060_LHR_SUB_DEV, 0x49); REGISTER_I2C_PCI_DETECTOR("Palit 3060Ti", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3060TI_DEV, PALIT_SUB_VEN, PALIT_RTX3060TI_SUB_DEV, 0x49); -REGISTER_I2C_PCI_DETECTOR("Palit 3060Ti", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3060TI_LHR_DEV, PALIT_SUB_VEN, PALIT_RTX3060TI_LHR_SUB_DEV, 0x49); +REGISTER_I2C_PCI_DETECTOR("Palit 3060TI LHR", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3060TI_LHR_DEV, PALIT_SUB_VEN, NVIDIA_RTX3060TI_LHR_DEV, 0x49); REGISTER_I2C_PCI_DETECTOR("Palit 3070", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3070_DEV, PALIT_SUB_VEN, PALIT_RTX3070_SUB_DEV, 0x49); REGISTER_I2C_PCI_DETECTOR("Palit 3070 LHR", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3070_LHR_DEV, PALIT_SUB_VEN, PALIT_RTX3070_LHR_SUB_DEV, 0x49); REGISTER_I2C_PCI_DETECTOR("Palit 3070Ti GamingPro", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3070TI_DEV, PALIT_SUB_VEN, PALIT_RTX3070TI_GAMING_PRO_SUB_DEV, 0x49); @@ -49,5 +49,4 @@ REGISTER_I2C_PCI_DETECTOR("Palit 3080 LHR", DetectPNYGPUCont REGISTER_I2C_PCI_DETECTOR("Palit 3080Ti", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3080TI_DEV, PALIT_SUB_VEN, PALIT_RTX3080TI_SUB_DEV, 0x49); REGISTER_I2C_PCI_DETECTOR("Palit 3090", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3090_DEV, PALIT_SUB_VEN, PALIT_RTX3090_SUB_DEV, 0x49); REGISTER_I2C_PCI_DETECTOR("Palit GeForce RTX 3060 Ti Dual", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3060TI_DEV, NVIDIA_SUB_VEN, PALIT_RTX3060TI_SUB_DEV, 0x49); -REGISTER_I2C_PCI_DETECTOR("Palit GeForce RTX 3060 Ti Dual OC", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX3060TI_LHR_DEV, NVIDIA_SUB_VEN, PALIT_RTX3060TI_LHR_SUB_DEV, 0x49); -REGISTER_I2C_PCI_DETECTOR("NVIDIA RTX2080S", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX2080S_DEV, NVIDIA_SUB_VEN, NVIDIA_RTX2080S_DEV, 0x49); \ No newline at end of file +REGISTER_I2C_PCI_DETECTOR("NVIDIA RTX2080S", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX2080S_DEV, NVIDIA_SUB_VEN, NVIDIA_RTX2080S_DEV, 0x49); diff --git a/OpenRGB.pro b/OpenRGB.pro index e82b4f80..39ff44d7 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -1187,6 +1187,7 @@ win32:INCLUDEPATH += dependencies/openrazer-win32 \ wmi/ \ Controllers/AsusTUFLaptopController \ + Controllers/NVIDIAIlluminationController \ win32:SOURCES += \ # dependencies/hidapi/hidapi.c \ @@ -1289,6 +1290,10 @@ win32:SOURCES += Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopWMI.cpp \ Controllers/ENESMBusController/XPGSpectrixS40GDetect_Windows.cpp \ Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_SpectrixS40G_Windows.cpp \ + Controllers/NVIDIAIlluminationController/nvapi_accessor.cpp \ + Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.cpp \ + Controllers/NVIDIAIlluminationController/NVIDIAIlluminationControllerDetect.cpp \ + Controllers/NVIDIAIlluminationController/RGBController_NVIDIAIllumination.cpp \ Controllers/OpenRazerController/OpenRazerWindowsDetect.cpp \ Controllers/OpenRazerController/RGBController_OpenRazerWindows.cpp \ @@ -1307,6 +1312,9 @@ win32:HEADERS += AutoStart/AutoStart-Windows.h \ Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopWMI.h \ Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_SpectrixS40G_Windows.h \ + Controllers/NVIDIAIlluminationController/nvapi_accessor.h \ + Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.h \ + Controllers/NVIDIAIlluminationController/RGBController_NVIDIAIllumination.h \ Controllers/OpenRazerController/RGBController_OpenRazerWindows.h \ win32:contains(QMAKE_TARGET.arch, x86_64) { diff --git a/dependencies/NVFC/nvapi.cpp b/dependencies/NVFC/nvapi.cpp index 6af354dc..36862dd0 100644 --- a/dependencies/NVFC/nvapi.cpp +++ b/dependencies/NVFC/nvapi.cpp @@ -238,6 +238,16 @@ static NV_STATUS(*pNvAPI_I2CReadEx)( NV_I2C_INFO_V3* i2c_info, NV_U32 *unknown); +// Interface: 3DBF5764 +static NV_STATUS(*pNvAPI_GPU_ClientIllumZonesGetControl)( + NV_PHYSICAL_GPU_HANDLE physical_gpu_handle, + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* pIllumZonesControl); + +// Interface: 197D065E +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) { void *address = ((void *(*)(NV_U32))query_interface)(id); @@ -291,6 +301,8 @@ static void QueryInterfaces(FARPROC query_interface) QueryInterface(query_interface, 0x283AC65A, NvAPI_I2CWriteEx); QueryInterface(query_interface, 0x4D7B0709, NvAPI_I2CReadEx); + QueryInterface(query_interface, 0x3DBF5764, NvAPI_GPU_ClientIllumZonesGetControl); + QueryInterface(query_interface, 0x197D065E, NvAPI_GPU_ClientIllumZonesSetControl); } NV_STATUS NvAPI_Initialize() @@ -558,3 +570,21 @@ NV_STATUS NvAPI_I2CReadEx( ? (*pNvAPI_I2CReadEx)(physical_gpu_handle, i2c_info, unknown) : -1; } + +NV_STATUS NvAPI_GPU_ClientIllumZonesGetControl( + NV_PHYSICAL_GPU_HANDLE physical_gpu_handle, + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* pIllumZonesControl) +{ + return pNvAPI_GPU_ClientIllumZonesGetControl + ? (*pNvAPI_GPU_ClientIllumZonesGetControl)(physical_gpu_handle, pIllumZonesControl) + : -1; +} + +NV_STATUS NvAPI_GPU_ClientIllumZonesSetControl( + NV_PHYSICAL_GPU_HANDLE physical_gpu_handle, + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS* pIllumZonesControl) +{ + return pNvAPI_GPU_ClientIllumZonesSetControl + ? (*pNvAPI_GPU_ClientIllumZonesSetControl)(physical_gpu_handle, pIllumZonesControl) + : -1; +} \ No newline at end of file diff --git a/dependencies/NVFC/nvapi.h b/dependencies/NVFC/nvapi.h index e859b95e..73668b03 100644 --- a/dependencies/NVFC/nvapi.h +++ b/dependencies/NVFC/nvapi.h @@ -6,6 +6,7 @@ typedef int32_t NV_S32; typedef uint32_t NV_U32; typedef uint8_t NV_U8; +typedef uint16_t NV_U16; typedef NV_S32* NV_HANDLE; typedef NV_HANDLE NV_PHYSICAL_GPU_HANDLE; @@ -308,6 +309,564 @@ struct NV_I2C_INFO_V3 { NV_U32 is_port_id_set; }; +// NvAPI RGB related stuff (CMiller) + +typedef enum +{ + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_INVALID = 0, + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGB, + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED, + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGBW, + NV_GPU_CLIENT_ILLUM_ZONE_TYPE_SINGLE_COLOR, +} NV_GPU_CLIENT_ILLUM_ZONE_TYPE; + + +typedef enum +{ + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_GPU_TOP_0 = 0x00, + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_GPU_FRONT_0 = 0x08, + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_GPU_BACK_0 = 0x0C, + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_SLI_TOP_0 = 0x20, + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION_INVALID = 0xFFFFFFFF, +} NV_GPU_CLIENT_ILLUM_ZONE_LOCATION; + + +typedef enum +{ + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_HALF_HALT = 0, + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_FULL_HALT, + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_FULL_REPEAT, + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_INVALID = 0xFF, +} NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_TYPE; + + +typedef enum +{ + NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB = 0, // deprecated + NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB, // deprecated + + NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL = 0, + NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR, + + // Strictly add new control modes above this. + NV_GPU_CLIENT_ILLUM_CTRL_MODE_INVALID = 0xFF, +} NV_GPU_CLIENT_ILLUM_CTRL_MODE; + + +#define NV_GPU_CLIENT_ILLUM_ZONE_NUM_ZONES_MAX 32 + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGB +{ + NV_U8 rsvd; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGB; + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGBW +{ + NV_U8 rsvd; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGBW; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_INFO_V1 + * Describes the static information of illum zone type SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_SINGLE_COLOR +{ + NV_U8 rsvd; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_SINGLE_COLOR; + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_V1 +{ + NV_GPU_CLIENT_ILLUM_ZONE_TYPE type; + + /*! + * Index pointing to an Illumination Device that controls this zone. + */ + NV_U8 illumDeviceIdx; + + /*! + * Provider index for representing logical to physical zone mapping. + */ + NV_U8 provIdx; + + /*! + * Location of the zone on the board. + */ + NV_GPU_CLIENT_ILLUM_ZONE_LOCATION zoneLocation; + + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGB rgb; + NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_RGBW rgbw; + NV_GPU_CLIENT_ILLUM_ZONE_INFO_DATA_SINGLE_COLOR singleColor; + /*! + * Reserved bytes for possible future extension of this struct. + */ + NV_U8 rsvd[64]; + } data; + + NV_U8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_V1; + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_V1 +{ + /*! + * Version of structure. Must always be first member. + */ + NV_U32 version; + + /*! + * Number of illumination zones present. + */ + NV_U32 numIllumZones; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NV_U8 rsvd[64]; + NV_GPU_CLIENT_ILLUM_ZONE_INFO_V1 zones[NV_GPU_CLIENT_ILLUM_ZONE_NUM_ZONES_MAX]; +} NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_V1; + +#define NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_VER_1 MAKE_NVAPI_VERSION(NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_V1, 1) +#define NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_VER NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_VER_1 +typedef NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS_V1 NV_GPU_CLIENT_ILLUM_ZONE_INFO_PARAMS; + + + + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB_PARAMS +{ + /*! + * Red compenent of color applied to the zone. + */ + NV_U8 colorR; + + /*! + * Green compenent of color applied to the zone. + */ + NV_U8 colorG; + + /*! + * Blue compenent of color applied to the zone. + */ + NV_U8 colorB; + + /*! + * Brightness perecentage value of the zone. + */ + NV_U8 brightnessPct; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB_PARAMS; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB + * Data required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB_PARAMS rgbParams; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGB + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR +{ + /*! + * Type of cycle effect to apply. + */ + NV_GPU_CLIENT_ILLUM_PIECEWISE_LINEAR_CYCLE_TYPE cycleType; + + /*! + * Number of times to repeat function within group period. + */ + NV_U8 grpCount; + + /*! + * Time in ms to transition from color A to color B. + */ + NV_U16 riseTimems; + + /*! + * Time in ms to transition from color B to color A. + */ + NV_U16 fallTimems; + + /*! + * Time in ms to remain at color A before color A to color B transition. + */ + NV_U16 ATimems; + + /*! + * Time in ms to remain at color B before color B to color A transition. + */ + NV_U16 BTimems; + + /*! + * Time in ms to remain idle before next group of repeated function cycles. + */ + NV_U16 grpIdleTimems; + + /*! + * Time in ms to offset the cycle relative to other zones. + */ + NV_U16 phaseOffsetms; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB + * Data required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ + +#define NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS 2 + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGB +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB_PARAMS rgbParams[NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR piecewiseLinearData; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGB; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1 + * Describes the control data for illumination zone of type + * \ref NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB +{ + /*! + * Union of illumination zone control data for zone of type NV_GPU_CLIENT_ILLUM_ZONE_TYPE_RGB. + * Interpreted as per ctrlMode. + */ + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGB manualRGB; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGB piecewiseLinearRGB; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NV_U8 rsvd[64]; + } data; + + /*! + * Reserved for future. + */ + NV_U8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED_PARAMS +{ + /*! + * Brightness percentage value of the zone. + */ + NV_U8 brightnessPct; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED_PARAMS; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED + * Data required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGB. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED_PARAMS colorFixedParams; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED + * Data required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_COLOR_FIXED +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGB. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED_PARAMS colorFixedParams[NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR piecewiseLinearData; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_COLOR_FIXED; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1 + * Describes the control data for illum zone of type + * \ref NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED +{ + /*! + * Union of illum zone control data for zone of type NV_GPU_CLIENT_ILLUM_ZONE_TYPE_COLOR_FIXED. + * Interpreted as per ctrlMode. + */ + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_COLOR_FIXED manualColorFixed; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_COLOR_FIXED piecewiseLinearColorFixed; + /*! + * Reserved bytes for possible future extension of this struct. + */ + NV_U8 rsvd[64]; + } data; + + /*! + * Reserved for future. + */ + NV_U8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED; + +/*! + * Used in \ref NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW + * Parameters required to represent control mode of type + * \ref NV_GPU_CLIENT_ILLUM_CTRL_MODE_MANUAL_RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW_PARAMS +{ + /*! + * Red component of color applied to the zone. + */ + NV_U8 colorR; + + /*! + * Green component of color applied to the zone. + */ + NV_U8 colorG; + + /*! + * Blue component of color applied to the zone. + */ + NV_U8 colorB; + + /*! + * White component of color applied to the zone. + */ + NV_U8 colorW; + + /*! + * Brightness percentage value of the zone. + */ + NV_U8 brightnessPct; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW_PARAMS; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_RGBW + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_RGBW. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW_PARAMS rgbwParams; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW; + + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_RGBW + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGBW +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_RGBW. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW_PARAMS rgbwParams[NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR piecewiseLinearData; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGBW; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_V1 + * Describes the control data for illum zone of type + * \ref NV_GPU_ILLUM_ZONE_TYPE_RGBW. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGBW +{ + /*! + * Union of illum zone control data for zone of type NV_GPU_ILLUM_ZONE_TYPE_RGBW. + * Interpreted as per ctrlMode. + */ + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_RGBW manualRGBW; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_RGBW piecewiseLinearRGBW; + /*! + * Reserved bytes for possible future extension of this struct. + */ + NV_U8 rsvd[64]; + } data; + + /*! + * Reserved for future. + */ + NV_U8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGBW; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR_PARAMS +{ + /*! + * Brightness percentage value of the zone. + */ + NV_U8 brightnessPct; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR_PARAMS; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_MANUAL_SINGLE_COLOR. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR_PARAMS singleColorParams; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR + * Data required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_SINGLE_COLOR +{ + /*! + * Parameters required to represent control mode of type + * \ref NV_GPU_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_SINGLE_COLOR. + */ + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR_PARAMS singleColorParams[NV_GPU_CLIENT_ILLUM_CTRL_MODE_PIECEWISE_LINEAR_COLOR_ENDPOINTS]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR piecewiseLinearData; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_SINGLE_COLOR; + +/*! + * Used in \ref NV_GPU_ILLUM_ZONE_CONTROL_V1 + * Describes the control data for illum zone of type + * \ref NV_GPU_ILLUM_ZONE_TYPE_SINGLE_COLOR. + */ +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR +{ + /*! + * Union of illum zone control data for zone of type NV_GPU_ILLUM_ZONE_TYPE_SINGLE_COLOR. + * Interpreted as per ctrlMode. + */ + union + { + // + // Need to be careful when add/expanding types in this union. If any type + // exceeds sizeof(rsvd) then rsvd has failed its purpose. + // + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_MANUAL_SINGLE_COLOR manualSingleColor; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_PIECEWISE_LINEAR_SINGLE_COLOR piecewiseLinearSingleColor; + /*! + * Reserved bytes for possible future extension of this struct. + */ + NV_U8 rsvd[64]; + } data; + + /*! + * Reserved for future. + */ + NV_U8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR; + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1 +{ + NV_GPU_CLIENT_ILLUM_ZONE_TYPE type; + NV_GPU_CLIENT_ILLUM_CTRL_MODE ctrlMode; + union + { + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGB rgb; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_COLOR_FIXED colorFixed; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_RGBW rgbw; + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_DATA_SINGLE_COLOR singleColor; + NV_U8 rsvd[64]; + } data; + NV_U8 rsvd[64]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1; + +typedef struct _NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_V1 +{ + NV_U32 version; + + /*! + * Bit field specifying the set of values to retrieve or set + * - default (NV_TRUE) + * - currently active (NV_FALSE). + */ + NV_U32 bDefault : 1; + NV_U32 rsvdField : 31; + + /*! + * Number of illumination zones present. + */ + NV_U32 numIllumZonesControl; + + /*! + * Reserved bytes for possible future extension of this struct. + */ + NV_U8 rsvd[64]; + + NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_V1 zones[NV_GPU_CLIENT_ILLUM_ZONE_NUM_ZONES_MAX]; +} NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_V1; + +#define NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_VER_1 MAKE_NVAPI_VERSION(NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_V1, 1) +#define NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_VER NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_VER_1 +typedef NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS_V1 NV_GPU_CLIENT_ILLUM_ZONE_CONTROL_PARAMS; + + + // Interface: 0150E828 NV_STATUS NvAPI_Initialize(); @@ -462,4 +1021,15 @@ NV_STATUS NvAPI_I2CReadEx( NV_PHYSICAL_GPU_HANDLE physical_gpu_handle, NV_I2C_INFO_V3* i2c_info, NV_U32 *unknown); + +// Interface: 73C01D58 +NV_STATUS NvAPI_GPU_ClientIllumZonesGetControl( + __in NV_PHYSICAL_GPU_HANDLE physical_gpu_handle, + __inout 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); + #endif diff --git a/pci_ids/pci_ids.h b/pci_ids/pci_ids.h index c59fb23b..a16f6e9d 100644 --- a/pci_ids/pci_ids.h +++ b/pci_ids/pci_ids.h @@ -75,6 +75,7 @@ #define NVIDIA_RTX3060_LHR_DEV 0x2504 #define NVIDIA_RTX3060TI_DEV 0x2486 #define NVIDIA_RTX3060TI_LHR_DEV 0x2489 +#define NVIDIA_RTX3060TI_V1_LHR_DEV 0x2414 #define NVIDIA_RTX3070_DEV 0x2484 #define NVIDIA_RTX3070_LHR_DEV 0x2488 #define NVIDIA_RTX3070TI_DEV 0x2482 @@ -85,6 +86,15 @@ #define NVIDIA_RTX3090_DEV 0x2204 #define NVIDIA_RTX3090TI_DEV 0x2203 +/*-----------------------------------------------------*\ +| nVidia Sub-Device IDs | +\*-----------------------------------------------------*/ +#define NVIDIA_RTX2070_FE_SUPER_SUB_DEV 0x13AA +#define NVIDIA_RTX3080_FE_SUB_DEV 0x1467 +#define NVIDIA_RTX3080TI_FE_SUB_DEV 0x1535 +#define NVIDIA_RTX3090_FE_SUB_DEV 0x147D +#define NVIDIA_RTX3090TI_FE_SUB_DEV 0x1618 + /*---------------------------------------------------------*\ | PCI Sub-Vendor IDs | \*---------------------------------------------------------*/ @@ -412,6 +422,7 @@ | PNY Sub-Device IDs | \*-----------------------------------------------------*/ #define PNY_RTX_3090_XLR8_REVEL_EPIC_X_SUB_DEV 0x136A +#define PNY_RTX_3060TI_XLR8_REVEL_EPIC_X_SUB_DEV 0x1389 /*-----------------------------------------------------*\ | Palit Sub-Device IDs | @@ -420,7 +431,6 @@ #define PALIT_RTX3060_LHR_SUB_DEV 0x2504 #define PALIT_RTX3060TI_SUB_DEV 0x2486 -#define PALIT_RTX3060TI_LHR_SUB_DEV 0x2489 #define PALIT_RTX3070_SUB_DEV 0x2484 #define PALIT_RTX3070_LHR_SUB_DEV 0x2488