Store name in GainwardGPUControllers to avoid setting it in detectors

This commit is contained in:
Adam Honse 2025-08-08 11:21:25 -05:00
parent 8813c9936d
commit 0afcdbd0ca
7 changed files with 32 additions and 16 deletions

View file

@ -77,9 +77,8 @@ void DetectGainwardGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, co
\*-----------------------------------------------------------------*/ \*-----------------------------------------------------------------*/
case 0x08: case 0x08:
{ {
GainwardGPUv1Controller* controller = new GainwardGPUv1Controller(bus, i2c_addr); GainwardGPUv1Controller* controller = new GainwardGPUv1Controller(bus, i2c_addr, name);
RGBController_GainwardGPUv1* rgb_controller = new RGBController_GainwardGPUv1(controller); RGBController_GainwardGPUv1* rgb_controller = new RGBController_GainwardGPUv1(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
@ -90,9 +89,8 @@ void DetectGainwardGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, co
\*-----------------------------------------------------------------*/ \*-----------------------------------------------------------------*/
case 0x49: case 0x49:
{ {
GainwardGPUv2Controller* controller = new GainwardGPUv2Controller(bus, i2c_addr); GainwardGPUv2Controller* controller = new GainwardGPUv2Controller(bus, i2c_addr, name);
RGBController_GainwardGPUv2* rgb_controller = new RGBController_GainwardGPUv2(controller); RGBController_GainwardGPUv2* rgb_controller = new RGBController_GainwardGPUv2(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }

View file

@ -12,10 +12,11 @@
#include <cstring> #include <cstring>
#include "GainwardGPUv1Controller.h" #include "GainwardGPUv1Controller.h"
GainwardGPUv1Controller::GainwardGPUv1Controller(i2c_smbus_interface* bus, gainward_gpu_dev_id dev) GainwardGPUv1Controller::GainwardGPUv1Controller(i2c_smbus_interface* bus, gainward_gpu_dev_id dev, std::string dev_name)
{ {
this->bus = bus; this->bus = bus;
this->dev = dev; this->dev = dev;
this->name = dev_name;
} }
GainwardGPUv1Controller::~GainwardGPUv1Controller() GainwardGPUv1Controller::~GainwardGPUv1Controller()
@ -33,6 +34,11 @@ std::string GainwardGPUv1Controller::GetDeviceLocation()
return("I2C: " + return_string); return("I2C: " + return_string);
} }
std::string GainwardGPUv1Controller::GetDeviceName()
{
return(name);
}
unsigned char GainwardGPUv1Controller::GetLEDRed() unsigned char GainwardGPUv1Controller::GetLEDRed()
{ {
return(GainwardGPURegisterRead(GAINWARD_RED_REGISTER)); return(GainwardGPURegisterRead(GAINWARD_RED_REGISTER));

View file

@ -28,10 +28,12 @@ enum
class GainwardGPUv1Controller class GainwardGPUv1Controller
{ {
public: public:
GainwardGPUv1Controller(i2c_smbus_interface* bus, gainward_gpu_dev_id); GainwardGPUv1Controller(i2c_smbus_interface* bus, gainward_gpu_dev_id, std::string dev_name);
~GainwardGPUv1Controller(); ~GainwardGPUv1Controller();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetDeviceName();
unsigned char GetLEDRed(); unsigned char GetLEDRed();
unsigned char GetLEDGreen(); unsigned char GetLEDGreen();
unsigned char GetLEDBlue(); unsigned char GetLEDBlue();
@ -44,4 +46,5 @@ public:
private: private:
i2c_smbus_interface * bus; i2c_smbus_interface * bus;
gainward_gpu_dev_id dev; gainward_gpu_dev_id dev;
std::string name;
}; };

View file

@ -32,10 +32,10 @@ RGBController_GainwardGPUv1::RGBController_GainwardGPUv1(GainwardGPUv1Controller
{ {
controller = controller_ptr; controller = controller_ptr;
name = "Gainward GPU"; name = controller->GetDeviceName();
vendor = "Gainward"; vendor = "Gainward";
type = DEVICE_TYPE_GPU; type = DEVICE_TYPE_GPU;
description = "Gainward GTX GPU"; description = "Gainward GPU V1 Device";
location = controller->GetDeviceLocation(); location = controller->GetDeviceLocation();
mode Direct; mode Direct;

View file

@ -12,10 +12,11 @@
#include <cstring> #include <cstring>
#include "GainwardGPUv2Controller.h" #include "GainwardGPUv2Controller.h"
GainwardGPUv2Controller::GainwardGPUv2Controller(i2c_smbus_interface* bus, gainward_gpu_dev_id dev) GainwardGPUv2Controller::GainwardGPUv2Controller(i2c_smbus_interface* bus, gainward_gpu_dev_id dev, std::string dev_name)
{ {
this->bus = bus; this->bus = bus;
this->dev = dev; this->dev = dev;
this->name = dev_name;
} }
GainwardGPUv2Controller::~GainwardGPUv2Controller() = default; GainwardGPUv2Controller::~GainwardGPUv2Controller() = default;
@ -30,6 +31,11 @@ std::string GainwardGPUv2Controller::GetDeviceLocation()
return("I2C: " + return_string); return("I2C: " + return_string);
} }
std::string GainwardGPUv2Controller::GetDeviceName()
{
return(name);
}
unsigned char GainwardGPUv2Controller::GetLEDRed() unsigned char GainwardGPUv2Controller::GetLEDRed()
{ {
return(bus->i2c_smbus_read_byte_data(dev, GAINWARD_V2_RED_REGISTER)); return(bus->i2c_smbus_read_byte_data(dev, GAINWARD_V2_RED_REGISTER));

View file

@ -80,10 +80,12 @@ enum
class GainwardGPUv2Controller class GainwardGPUv2Controller
{ {
public: public:
GainwardGPUv2Controller(i2c_smbus_interface* bus, gainward_gpu_dev_id); GainwardGPUv2Controller(i2c_smbus_interface* bus, gainward_gpu_dev_id, std::string dev_name);
~GainwardGPUv2Controller(); ~GainwardGPUv2Controller();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetDeviceName();
unsigned char GetLEDRed(); unsigned char GetLEDRed();
unsigned char GetLEDGreen(); unsigned char GetLEDGreen();
unsigned char GetLEDBlue(); unsigned char GetLEDBlue();
@ -95,4 +97,5 @@ public:
private: private:
i2c_smbus_interface * bus; i2c_smbus_interface * bus;
gainward_gpu_dev_id dev; gainward_gpu_dev_id dev;
std::string name;
}; };

View file

@ -26,10 +26,10 @@ RGBController_GainwardGPUv2::RGBController_GainwardGPUv2(GainwardGPUv2Controller
{ {
controller = controller_ptr; controller = controller_ptr;
name = "Gainward GPU"; name = controller->GetDeviceName();
vendor = "Gainward"; vendor = "Gainward";
type = DEVICE_TYPE_GPU; type = DEVICE_TYPE_GPU;
description = "Gainward RTX GPU"; description = "Gainward GPU V2 Device";
location = controller->GetDeviceLocation(); location = controller->GetDeviceLocation();
mode Static; mode Static;