Rework EVGAGP102GPUController to use I2C PCI detector and store name in controller to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-07 11:46:12 -05:00
parent c94eed432d
commit c32663bb32
6 changed files with 82 additions and 98 deletions

View file

@ -516,7 +516,7 @@ void EVGAGPUv3Controller::SetZone(uint8_t zone, uint8_t mode, EVGAv3_config zone
break; break;
default: default:
{ {
LOG_TRACE("[%s] Mode %02d not found", name->c_str(), mode); LOG_TRACE("[%s] Mode %02d not found", name.c_str(), mode);
} }
break; break;
} }

View file

@ -12,10 +12,11 @@
#include "EVGAGP102Controller.h" #include "EVGAGP102Controller.h"
#include "LogManager.h" #include "LogManager.h"
EVGAGP102Controller::EVGAGP102Controller(i2c_smbus_interface* bus_ptr, zoneinfo info) EVGAGP102Controller::EVGAGP102Controller(i2c_smbus_interface* bus_ptr, zoneinfo info, std::string dev_name)
{ {
bus = bus_ptr; bus = bus_ptr;
zi = info; zi = info;
name = dev_name;
} }
EVGAGP102Controller::~EVGAGP102Controller() EVGAGP102Controller::~EVGAGP102Controller()
@ -32,6 +33,16 @@ std::string EVGAGP102Controller::GetDeviceLocation()
return("I2C: " + return_string); 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) void EVGAGP102Controller::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{ {
SendCommand(EVGA_GP102_CMD_BEGIN); SendCommand(EVGA_GP102_CMD_BEGIN);
@ -125,8 +136,3 @@ void EVGAGP102Controller::SaveSettings()
//bus->i2c_smbus_write_byte_data(zi.dev_addr, 0x21, 0xE5); //bus->i2c_smbus_write_byte_data(zi.dev_addr, 0x21, 0xE5);
//bus->i2c_smbus_write_byte_data(zi.dev_addr, 0x22, 0xE7); //bus->i2c_smbus_write_byte_data(zi.dev_addr, 0x22, 0xE7);
} }
std::string EVGAGP102Controller::GetName()
{
return zi.zone_name;
}

View file

@ -82,12 +82,13 @@ const static zoneinfo gpuzoneinfos[]
class EVGAGP102Controller class EVGAGP102Controller
{ {
public: public:
EVGAGP102Controller(i2c_smbus_interface* bus, zoneinfo info); EVGAGP102Controller(i2c_smbus_interface* bus, zoneinfo info, std::string dev_name);
~EVGAGP102Controller(); ~EVGAGP102Controller();
bool IsValid(); bool IsValid();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetName(); std::string GetDeviceName();
std::string GetZoneName();
unsigned char GetMode(); unsigned char GetMode();
void SetColor(unsigned char red, unsigned char green, unsigned char blue); void SetColor(unsigned char red, unsigned char green, unsigned char blue);
@ -96,6 +97,10 @@ public:
void SaveSettings(); void SaveSettings();
private: private:
i2c_smbus_interface* bus;
zoneinfo zi;
std::string name;
bool CommandAcknowledged(); bool CommandAcknowledged();
bool CommandCompleted(); bool CommandCompleted();
s32 QueryCommand(s32 command); s32 QueryCommand(s32 command);
@ -103,8 +108,4 @@ private:
unsigned char GetRed(); unsigned char GetRed();
unsigned char GetGreen(); unsigned char GetGreen();
unsigned char GetBlue(); unsigned char GetBlue();
i2c_smbus_interface* bus;
zoneinfo zi;
}; };

View file

@ -17,28 +17,6 @@
#include "i2c_smbus.h" #include "i2c_smbus.h"
#include "pci_ids.h" #include "pci_ids.h"
typedef struct
{
int pci_vendor;
int pci_device;
int pci_subsystem_vendor;
int pci_subsystem_device;
const char * name;
} gpu_pci_device;
#define GPU_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const gpu_pci_device device_list[] =
{
{ NVIDIA_VEN, NVIDIA_GTX1070_DEV, EVGA_SUB_VEN, EVGA_GTX1070_FTW2_SUB_DEV, "EVGA GeForce GTX 1070 FTW2 Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1080_DEV, EVGA_SUB_VEN, EVGA_GTX1080_FTW2_SUB_DEV, "EVGA GeForce GTX 1080 FTW2 Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1080_DEV, EVGA_SUB_VEN, EVGA_GTX1080_FTW2_11G_SUB_DEV, "EVGA GeForce GTX 1080 FTW2 11G" },
{ NVIDIA_VEN, NVIDIA_GTX1080_DEV, EVGA_SUB_VEN, EVGA_GTX1080_FTW2_DT_SUB_DEV, "EVGA GeForce GTX 1080 FTW2 DT" },
{ NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, EVGA_SUB_VEN, EVGA_GTX1080TI_SC2_GAMING_SUB_DEV, "EVGA GeForce GTX 1080 Ti SC2 Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, EVGA_SUB_VEN, EVGA_GTX1080TI_FTW3_SUB_DEV, "EVGA GeForce GTX 1080 Ti FTW3" },
{ NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, EVGA_SUB_VEN, EVGA_GTX1080TI_FTW3_HYBRID_SUB_DEV, "EVGA GeForce GTX 1080 Ti FTW3 Hybrid" },
{ NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, EVGA_SUB_VEN, EVGA_GTX1080TI_KINGPIN_SUB_DEV, "EVGA GeForce GTX 1080 Ti K|NGP|N" },
};
/******************************************************************************************\ /******************************************************************************************\
* * * *
* DetectEVGAGP102GPUControllers * * DetectEVGAGP102GPUControllers *
@ -46,51 +24,50 @@ static const gpu_pci_device device_list[] =
* Detect EVGA GP102 GPU controllers on the enumerated I2C busses at address 0x49. * * 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 * * bus - pointer to i2c_smbus_interface where EVGA GPU device is connected *
* dev - I2C address of EVGA GPU device * * address - unused, the address comes from the GPU zone info table *
* name - name string of detected PCI device *
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectEVGAGP102GPUControllers(std::vector<i2c_smbus_interface*>& busses) void DetectEVGAGP102GPUControllers(i2c_smbus_interface* bus, uint8_t /*address*/, const std::string& name)
{ {
for (unsigned int bus = 0; bus < busses.size(); bus++) if(bus->port_id == 1)
{ {
for(unsigned int dev_idx = 0; dev_idx < GPU_NUM_DEVICES; dev_idx++) RGBController_EVGAGP102* new_rgbcontroller;
std::vector<EVGAGP102Controller*> controllers;
for(unsigned int i = 0; i < sizeof(gpuzoneinfos) / sizeof(zoneinfo); i++)
{ {
if (busses[bus]->port_id != 1) EVGAGP102Controller* controller = new EVGAGP102Controller(bus, gpuzoneinfos[i], name);
{
break;
}
if(busses[bus]->pci_vendor == device_list[dev_idx].pci_vendor && if(controller->IsValid())
busses[bus]->pci_device == device_list[dev_idx].pci_device &&
busses[bus]->pci_subsystem_vendor == device_list[dev_idx].pci_subsystem_vendor &&
busses[bus]->pci_subsystem_device == device_list[dev_idx].pci_subsystem_device)
{ {
LOG_DEBUG(GPU_DETECT_MESSAGE, EVGA_GP102_CONTROLLER_NAME, bus, device_list[dev_idx].pci_device, device_list[dev_idx].pci_subsystem_device, device_list[dev_idx].name ); controllers.push_back(controller);
RGBController_EVGAGP102* new_rgbcontroller;
std::vector<EVGAGP102Controller*> controllers;
for(unsigned int i = 0; i < sizeof(gpuzoneinfos) / sizeof(zoneinfo); i++)
{
EVGAGP102Controller* contr = new EVGAGP102Controller(busses[bus], gpuzoneinfos[i]);
if (contr->IsValid())
{
controllers.push_back(contr);
}
else
{
delete contr;
}
}
if(controllers.size() != 0)
{
new_rgbcontroller = new RGBController_EVGAGP102(controllers);
new_rgbcontroller->name = device_list[dev_idx].name;
ResourceManager::get()->RegisterRGBController(new_rgbcontroller);
}
} }
else
{
delete controller;
}
}
if(controllers.size() != 0)
{
new_rgbcontroller = new RGBController_EVGAGP102(controllers);
ResourceManager::get()->RegisterRGBController(new_rgbcontroller);
} }
} }
} /* DetectEVGAGP102GPUControllers() */ } /* DetectEVGAGP102GPUControllers() */
REGISTER_I2C_DETECTOR("EVGA GP102 GPU", 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 );

View file

@ -23,40 +23,40 @@
@comment @comment
\*-------------------------------------------------------------------*/ \*-------------------------------------------------------------------*/
RGBController_EVGAGP102::RGBController_EVGAGP102(std::vector<EVGAGP102Controller*> evga_ptr) RGBController_EVGAGP102::RGBController_EVGAGP102(std::vector<EVGAGP102Controller*> controller_list)
{ {
evga = evga_ptr; controllers = controller_list;
name = "EVGA GP102 GPU"; name = controllers[0]->GetDeviceName();
vendor = "EVGA"; vendor = "EVGA";
description = "EVGA GP102-based RGB GPU Device"; description = "EVGA GP102-based RGB GPU Device";
for(unsigned int i = 0; i < zones.size(); i++) for(unsigned int i = 0; i < zones.size(); i++)
{ {
location += evga[i]->GetDeviceLocation() + " "; location += controllers[i]->GetDeviceLocation() + " ";
} }
type = DEVICE_TYPE_GPU; type = DEVICE_TYPE_GPU;
mode Off; mode Off;
Off.name = "Off"; Off.name = "Off";
Off.value = EVGA_GP102_MODE_OFF; Off.value = EVGA_GP102_MODE_OFF;
Off.flags = 0; Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE; Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off); modes.push_back(Off);
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
Direct.value = EVGA_GP102_MODE_CUSTOM; Direct.value = EVGA_GP102_MODE_CUSTOM;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED; Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct); modes.push_back(Direct);
SetupZones(); SetupZones();
// Initialize active mode and stored color // Initialize active mode and stored color
unsigned char raw_active_mode = evga[0]->GetMode(); unsigned char raw_active_mode = controllers[0]->GetMode();
active_mode = 0; active_mode = 0;
for(unsigned int i = 0; i < modes.size(); i++) for(unsigned int i = 0; i < modes.size(); i++)
@ -69,7 +69,7 @@ RGBController_EVGAGP102::RGBController_EVGAGP102(std::vector<EVGAGP102Controller
} }
for(unsigned int i = 0; i < zones.size(); i++) for(unsigned int i = 0; i < zones.size(); i++)
{ {
std::array<unsigned char, 3> rgb = evga[i]->GetColor(); std::array<unsigned char, 3> rgb = controllers[i]->GetColor();
colors[i] = ToRGBColor(rgb[0], rgb[1], rgb[2]); colors[i] = ToRGBColor(rgb[0], rgb[1], rgb[2]);
} }
@ -77,9 +77,9 @@ RGBController_EVGAGP102::RGBController_EVGAGP102(std::vector<EVGAGP102Controller
RGBController_EVGAGP102::~RGBController_EVGAGP102() RGBController_EVGAGP102::~RGBController_EVGAGP102()
{ {
for(unsigned int i = 0; i < evga.size(); i++) for(unsigned int i = 0; i < controllers.size(); i++)
{ {
delete evga[i]; delete controllers[i];
} }
} }
@ -91,19 +91,19 @@ void RGBController_EVGAGP102::SetupZones()
| the backplate logo (K|NGP|N logo, or EVGA GeForce 1080 Ti | | the backplate logo (K|NGP|N logo, or EVGA GeForce 1080 Ti |
| for the FTW3). | for the FTW3).
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
for(unsigned int i = 0; i < evga.size(); i++) for(unsigned int i = 0; i < controllers.size(); i++)
{ {
zone new_zone; zone new_zone;
led new_led; led new_led;
new_zone.name = evga[i]->GetName(); new_zone.name = controllers[i]->GetZoneName();
new_zone.type = ZONE_TYPE_SINGLE; new_zone.type = ZONE_TYPE_SINGLE;
new_zone.leds_min = 1; new_zone.leds_min = 1;
new_zone.leds_max = 1; new_zone.leds_max = 1;
new_zone.leds_count = 1; new_zone.leds_count = 1;
new_zone.matrix_map = NULL; new_zone.matrix_map = NULL;
new_led.name = evga[i]->GetName(); new_led.name = controllers[i]->GetZoneName();
leds.push_back(new_led); leds.push_back(new_led);
zones.push_back(new_zone); zones.push_back(new_zone);
@ -133,7 +133,7 @@ void RGBController_EVGAGP102::UpdateZoneLEDs(int zone)
unsigned char red = RGBGetRValue(color); unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color); unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color); unsigned char blu = RGBGetBValue(color);
evga[zone]->SetColor(red, grn, blu); controllers[zone]->SetColor(red, grn, blu);
} }
void RGBController_EVGAGP102::UpdateSingleLED(int /*led*/) void RGBController_EVGAGP102::UpdateSingleLED(int /*led*/)
@ -143,9 +143,9 @@ void RGBController_EVGAGP102::UpdateSingleLED(int /*led*/)
void RGBController_EVGAGP102::DeviceUpdateMode() void RGBController_EVGAGP102::DeviceUpdateMode()
{ {
for(unsigned int i = 0; i < evga.size(); i++) for(unsigned int i = 0; i < controllers.size(); i++)
{ {
evga[i]->SetMode((unsigned char)modes[(unsigned int)active_mode].value); controllers[i]->SetMode((unsigned char)modes[(unsigned int)active_mode].value);
} }
} }

View file

@ -17,7 +17,7 @@
class RGBController_EVGAGP102 : public RGBController class RGBController_EVGAGP102 : public RGBController
{ {
public: public:
RGBController_EVGAGP102(std::vector<EVGAGP102Controller*> evga_ptr); RGBController_EVGAGP102(std::vector<EVGAGP102Controller*> controller_list);
~RGBController_EVGAGP102(); ~RGBController_EVGAGP102();
void SetupZones(); void SetupZones();
@ -32,5 +32,5 @@ public:
void DeviceSaveMode(); void DeviceSaveMode();
private: private:
std::vector<EVGAGP102Controller*> evga; std::vector<EVGAGP102Controller*> controllers;
}; };