Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,138 @@
/*---------------------------------------------------------*\
| EVGAGP102Controller.cpp |
| |
| Driver for EVGA GP102 GPU |
| |
| Fabricio Murta (avengerx) 31 Jan 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "EVGAGP102Controller.h"
#include "LogManager.h"
EVGAGP102Controller::EVGAGP102Controller(i2c_smbus_interface* bus_ptr, zoneinfo info, std::string dev_name)
{
bus = bus_ptr;
zi = info;
name = dev_name;
}
EVGAGP102Controller::~EVGAGP102Controller()
{
}
std::string EVGAGP102Controller::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", zi.dev_addr);
return_string.append(", address ");
return_string.append(addr);
return("I2C: " + return_string);
}
std::string EVGAGP102Controller::GetDeviceName()
{
return(name);
}
std::string EVGAGP102Controller::GetZoneName()
{
return(zi.zone_name);
}
void EVGAGP102Controller::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
SendCommand(EVGA_GP102_CMD_BEGIN);
SendCommand(EVGA_GP102_CMD_COLOR);
if (CommandAcknowledged())
{
unsigned char rgb[] = { red, green, blue };
for (int i = 0; i < 3; i++)
{
bus->i2c_smbus_write_byte_data(zi.dev_addr, zi.color_addrs[i], rgb[i]);
}
SendCommand(EVGA_GP102_CMD_END);
if (!CommandCompleted())
{
LOG_WARNING("[%s] Non-clear status report from hardware.", EVGA_GP102_CONTROLLER_NAME);
}
}
}
std::array<unsigned char, 3> EVGAGP102Controller::GetColor()
{
return { GetRed(), GetGreen(), GetBlue() };
}
bool EVGAGP102Controller::IsValid()
{
for (int i = 0; i < 3; i++)
{
unsigned char res = bus->i2c_smbus_read_byte_data(zi.dev_addr, EVGA_GP102_REG_VALID);
if (res == 0x1F || res == 0x91)
{
LOG_TRACE("[%s] Zone discovery successful on address: 0x%02X.", EVGA_GP102_CONTROLLER_NAME, zi.dev_addr);
return true;
}
LOG_DEBUG("[%s] Zone discovery failed on address: 0x%02X expected: 0x1F received: 0x%02X.", EVGA_GP102_CONTROLLER_NAME, zi.dev_addr, res);
}
return false;
}
void EVGAGP102Controller::SetMode(unsigned char mode)
{
bus->i2c_smbus_write_byte_data(zi.dev_addr, EVGA_GP102_REG_MODE, mode);
}
unsigned char EVGAGP102Controller::GetMode()
{
return(bus->i2c_smbus_read_byte_data(zi.dev_addr, EVGA_GP102_REG_MODE));
}
void EVGAGP102Controller::SendCommand(s32 command)
{
bus->i2c_smbus_write_byte_data(zi.dev_addr, EVGA_GP102_REG_CMD, command);
}
s32 EVGAGP102Controller::QueryCommand(s32 command)
{
return bus->i2c_smbus_read_byte_data(zi.dev_addr, command);
}
bool EVGAGP102Controller::CommandAcknowledged()
{
return QueryCommand(EVGA_GP102_REG_CMD) == zi.resp_ready;
}
bool EVGAGP102Controller::CommandCompleted()
{
return QueryCommand(EVGA_GP102_REG_CMD) == zi.resp_clear;
}
unsigned char EVGAGP102Controller::GetRed()
{
return(bus->i2c_smbus_read_byte_data(zi.dev_addr, zi.color_addrs[EVGA_GP102_CIDX_RED]));
}
unsigned char EVGAGP102Controller::GetGreen()
{
return(bus->i2c_smbus_read_byte_data(zi.dev_addr, zi.color_addrs[EVGA_GP102_CIDX_GREEN]));
}
unsigned char EVGAGP102Controller::GetBlue()
{
return(bus->i2c_smbus_read_byte_data(zi.dev_addr, zi.color_addrs[EVGA_GP102_CIDX_BLUE]));
}
void EVGAGP102Controller::SaveSettings()
{
//Tested and not worked
//bus->i2c_smbus_write_byte_data(zi.dev_addr, 0x21, 0xE5);
//bus->i2c_smbus_write_byte_data(zi.dev_addr, 0x22, 0xE7);
}
@@ -0,0 +1,111 @@
/*---------------------------------------------------------*\
| EVGAGP102Controller.h |
| |
| Driver for EVGA GP102 GPU |
| |
| Fabricio Murta (avengerx) 31 Jan 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <vector>
#include "i2c_smbus.h"
#define EVGA_GP102_CONTROLLER_NAME "EVGA GP102 Nvidia GPU"
enum
{
EVGA_GP102_REG_MODE = 0x0C,
EVGA_GP102_REG_CMD = 0x0E,
EVGA_GP102_REG_VALID = 0x04
};
enum
{
EVGA_GP102_MODE_OFF = 0x00,
EVGA_GP102_MODE_CUSTOM = 0x01
// TODO: Other LEDSync modes (rainbow, breath, pulse)
};
enum
{
EVGA_GP102_CIDX_RED = 0,
EVGA_GP102_CIDX_GREEN = 1,
EVGA_GP102_CIDX_BLUE = 2
};
enum
{
EVGA_GP102_CMD_BEGIN = 0xE5,
EVGA_GP102_CMD_COLOR = 0xE9,
EVGA_GP102_CMD_END = 0xE0
};
typedef struct
{
std::string zone_name;
s32 dev_addr;
s32 color_addrs[3];
s32 resp_ready;
s32 resp_clear;
} zoneinfo;
const static zoneinfo gpuzoneinfos[]
{
{
"Nameplate",
0x4A,
{0x09, 0x0A, 0x0B},
0x03,
0x00
},
{
"Backplate", // for 1080Ti K|NGP|N
0x2A,
{0x30, 0x31, 0x32},
0xE9,
0xE0
},
{
"Backplate", // for 1080Ti FTW3
0x4F,
{0x30, 0x31, 0x32},
0x03,
0x00
},
};
class EVGAGP102Controller
{
public:
EVGAGP102Controller(i2c_smbus_interface* bus, zoneinfo info, std::string dev_name);
~EVGAGP102Controller();
bool IsValid();
std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetZoneName();
unsigned char GetMode();
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
std::array<unsigned char, 3> GetColor();
void SetMode(unsigned char mode);
void SaveSettings();
private:
i2c_smbus_interface* bus;
zoneinfo zi;
std::string name;
bool CommandAcknowledged();
bool CommandCompleted();
s32 QueryCommand(s32 command);
void SendCommand(s32 command);
unsigned char GetRed();
unsigned char GetGreen();
unsigned char GetBlue();
};
@@ -0,0 +1,73 @@
/*---------------------------------------------------------*\
| EVGAGP102ControllerDetect.cpp |
| |
| Detector for EVGA GP102 GPU |
| |
| Fabricio Murta (avengerx) 31 Jan 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <vector>
#include "Detector.h"
#include "EVGAGP102Controller.h"
#include "LogManager.h"
#include "RGBController_EVGAGP102.h"
#include "i2c_smbus.h"
#include "pci_ids.h"
/******************************************************************************************\
* *
* DetectEVGAGP102GPUControllers *
* *
* Detect EVGA GP102 GPU controllers on the enumerated I2C busses at address 0x49. *
* *
* bus - pointer to i2c_smbus_interface where EVGA GPU device is connected *
* address - unused, the address comes from the GPU zone info table *
* name - name string of detected PCI device *
* *
\******************************************************************************************/
void DetectEVGAGP102GPUControllers(i2c_smbus_interface* bus, uint8_t /*address*/, const std::string& name)
{
if(bus->port_id == 1)
{
RGBController_EVGAGP102* new_rgbcontroller;
std::vector<EVGAGP102Controller*> controllers;
for(unsigned int i = 0; i < sizeof(gpuzoneinfos) / sizeof(zoneinfo); i++)
{
EVGAGP102Controller* controller = new EVGAGP102Controller(bus, gpuzoneinfos[i], name);
if(controller->IsValid())
{
controllers.push_back(controller);
}
else
{
delete controller;
}
}
if(controllers.size() != 0)
{
new_rgbcontroller = new RGBController_EVGAGP102(controllers);
ResourceManager::get()->RegisterRGBController(new_rgbcontroller);
}
}
} /* DetectEVGAGP102GPUControllers() */
/*---------------------------------------------------------*\
| The I2C address is provided by the GPU Zone Info table, |
| as these GPUs have multiple I2C devices per card. |
\*---------------------------------------------------------*/
REGISTER_I2C_PCI_DETECTOR( "EVGA GeForce GTX 1070 FTW2 Gaming", DetectEVGAGP102GPUControllers, NVIDIA_VEN, NVIDIA_GTX1070_DEV, EVGA_SUB_VEN, EVGA_GTX1070_FTW2_SUB_DEV, 0x00 );
REGISTER_I2C_PCI_DETECTOR( "EVGA GeForce GTX 1080 FTW2 Gaming", DetectEVGAGP102GPUControllers, NVIDIA_VEN, NVIDIA_GTX1080_DEV, EVGA_SUB_VEN, EVGA_GTX1080_FTW2_SUB_DEV, 0x00 );
REGISTER_I2C_PCI_DETECTOR( "EVGA GeForce GTX 1080 FTW2 11G", DetectEVGAGP102GPUControllers, NVIDIA_VEN, NVIDIA_GTX1080_DEV, EVGA_SUB_VEN, EVGA_GTX1080_FTW2_11G_SUB_DEV, 0x00 );
REGISTER_I2C_PCI_DETECTOR( "EVGA GeForce GTX 1080 FTW2 DT", DetectEVGAGP102GPUControllers, NVIDIA_VEN, NVIDIA_GTX1080_DEV, EVGA_SUB_VEN, EVGA_GTX1080_FTW2_DT_SUB_DEV, 0x00 );
REGISTER_I2C_PCI_DETECTOR( "EVGA GeForce GTX 1080 Ti SC2 Gaming", DetectEVGAGP102GPUControllers, NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, EVGA_SUB_VEN, EVGA_GTX1080TI_SC2_GAMING_SUB_DEV, 0x00 );
REGISTER_I2C_PCI_DETECTOR( "EVGA GeForce GTX 1080 Ti FTW3", DetectEVGAGP102GPUControllers, NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, EVGA_SUB_VEN, EVGA_GTX1080TI_FTW3_SUB_DEV, 0x00 );
REGISTER_I2C_PCI_DETECTOR( "EVGA GeForce GTX 1080 Ti FTW3 Hybrid", DetectEVGAGP102GPUControllers, NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, EVGA_SUB_VEN, EVGA_GTX1080TI_FTW3_HYBRID_SUB_DEV, 0x00 );
REGISTER_I2C_PCI_DETECTOR( "EVGA GeForce GTX 1080 Ti K|NGP|N", DetectEVGAGP102GPUControllers, NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, EVGA_SUB_VEN, EVGA_GTX1080TI_KINGPIN_SUB_DEV, 0x00 );
@@ -0,0 +1,154 @@
/*---------------------------------------------------------*\
| RGBController_EVGAGP102.cpp |
| |
| RGBController for EVGA GP102 GPU |
| |
| Fabricio Murta (avengerx) 31 Jan 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <array>
#include "RGBController_EVGAGP102.h"
/**------------------------------------------------------------------*\
@name EVGA GP102 GPU
@category GPU
@type I2C
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectEVGAGPUControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_EVGAGP102::RGBController_EVGAGP102(std::vector<EVGAGP102Controller*> controller_list)
{
controllers = controller_list;
name = controllers[0]->GetDeviceName();
vendor = "EVGA";
description = "EVGA GP102-based RGB GPU Device";
for(unsigned int i = 0; i < zones.size(); i++)
{
location += controllers[i]->GetDeviceLocation() + " ";
}
type = DEVICE_TYPE_GPU;
mode Off;
Off.name = "Off";
Off.value = EVGA_GP102_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Direct;
Direct.name = "Direct";
Direct.value = EVGA_GP102_MODE_CUSTOM;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
// Initialize active mode and stored color
unsigned char raw_active_mode = controllers[0]->GetMode();
active_mode = 0;
for(unsigned int i = 0; i < modes.size(); i++)
{
if (modes[i].value == raw_active_mode)
{
active_mode = i;
break;
}
}
for(unsigned int i = 0; i < zones.size(); i++)
{
std::array<unsigned char, 3> rgb = controllers[i]->GetColor();
colors[i] = ToRGBColor(rgb[0], rgb[1], rgb[2]);
}
}
RGBController_EVGAGP102::~RGBController_EVGAGP102()
{
for(unsigned int i = 0; i < controllers.size(); i++)
{
delete controllers[i];
}
}
void RGBController_EVGAGP102::SetupZones()
{
/*---------------------------------------------------------*\
| This device basically has two controllable zones, one at |
| the top of the board with GeForce 1080 Ti and another for |
| the backplate logo (K|NGP|N logo, or EVGA GeForce 1080 Ti |
| for the FTW3).
\*---------------------------------------------------------*/
for(unsigned int i = 0; i < controllers.size(); i++)
{
zone new_zone;
led new_led;
new_zone.name = controllers[i]->GetZoneName();
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 = controllers[i]->GetZoneName();
leds.push_back(new_led);
zones.push_back(new_zone);
}
SetupColors();
}
void RGBController_EVGAGP102::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_EVGAGP102::DeviceUpdateLEDs()
{
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
UpdateZoneLEDs(zone_idx);
}
}
void RGBController_EVGAGP102::UpdateZoneLEDs(int zone)
{
RGBColor color = colors[zone];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
controllers[zone]->SetColor(red, grn, blu);
}
void RGBController_EVGAGP102::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_EVGAGP102::DeviceUpdateMode()
{
for(unsigned int i = 0; i < controllers.size(); i++)
{
controllers[i]->SetMode((unsigned char)modes[(unsigned int)active_mode].value);
}
}
void RGBController_EVGAGP102::DeviceSaveMode()
{
}
@@ -0,0 +1,36 @@
/*---------------------------------------------------------*\
| RGBController_EVGAGP102.h |
| |
| RGBController for EVGA GP102 GPU |
| |
| Fabricio Murta (avengerx) 31 Jan 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "EVGAGP102Controller.h"
class RGBController_EVGAGP102 : public RGBController
{
public:
RGBController_EVGAGP102(std::vector<EVGAGP102Controller*> controller_list);
~RGBController_EVGAGP102();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceSaveMode();
private:
std::vector<EVGAGP102Controller*> controllers;
};