Store name in ColorfulGPUControllers to avoid setting it in detectors

This commit is contained in:
Adam Honse 2025-08-04 17:12:14 -05:00
parent 2ec68c29de
commit 526d35edfe
8 changed files with 32 additions and 14 deletions

View file

@ -12,10 +12,11 @@
#include "pci_ids.h"
#include "LogManager.h"
ColorfulGPUController::ColorfulGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev)
ColorfulGPUController::ColorfulGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev, std::string dev_name)
{
this->bus = bus;
this->dev = dev;
this->name = dev_name;
}
ColorfulGPUController::~ColorfulGPUController()
@ -33,6 +34,11 @@ std::string ColorfulGPUController::GetDeviceLocation()
return("I2C: " + return_string);
}
std::string ColorfulGPUController::GetDeviceName()
{
return(name);
}
void ColorfulGPUController::SetDirect(RGBColor color)
{
uint8_t r = RGBGetRValue(color);

View file

@ -21,13 +21,16 @@ typedef unsigned char colorful_gpu_dev_id;
class ColorfulGPUController
{
public:
ColorfulGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev);
ColorfulGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev, std::string dev_name);
~ColorfulGPUController();
std::string GetDeviceLocation();
std::string GetDeviceName();
void SetDirect(RGBColor color);
private:
i2c_smbus_interface * bus;
colorful_gpu_dev_id dev;
std::string name;
};

View file

@ -37,9 +37,8 @@ void DetectColorfulGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, co
{
if(TestForColorfulGPU(bus, i2c_addr))
{
ColorfulGPUController* controller = new ColorfulGPUController(bus, i2c_addr);
ColorfulGPUController* controller = new ColorfulGPUController(bus, i2c_addr, name);
RGBController_ColorfulGPU* rgb_controller = new RGBController_ColorfulGPU(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}

View file

@ -24,7 +24,8 @@
RGBController_ColorfulGPU::RGBController_ColorfulGPU(ColorfulGPUController * colorful_gpu_ptr)
{
controller = colorful_gpu_ptr;
name = "Colorful GPU Device";
name = controller->GetDeviceName();
vendor = "Colorful";
type = DEVICE_TYPE_GPU;
description = name;

View file

@ -10,10 +10,11 @@
#include <cstring>
#include "ColorfulTuringGPUController.h"
ColorfulTuringGPUController::ColorfulTuringGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev)
ColorfulTuringGPUController::ColorfulTuringGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev, std::string dev_name)
{
this->bus = bus;
this->dev = dev;
this->name = dev_name;
}
ColorfulTuringGPUController::~ColorfulTuringGPUController()
@ -31,6 +32,11 @@ std::string ColorfulTuringGPUController::GetDeviceLocation()
return("I2C: " + return_string);
}
std::string ColorfulTuringGPUController::GetDeviceName()
{
return(name);
}
int ColorfulTuringGPUController::GetMode()
{
uint8_t data_pkt[COLORFUL_MODE_PACKET_LENGTH];

View file

@ -31,10 +31,12 @@ enum
class ColorfulTuringGPUController
{
public:
ColorfulTuringGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev);
ColorfulTuringGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev, std::string dev_name);
~ColorfulTuringGPUController();
std::string GetDeviceLocation();
std::string GetDeviceName();
int GetMode();
RGBColor GetColor();
void SetDirect(RGBColor color, bool save);
@ -47,4 +49,5 @@ public:
private:
i2c_smbus_interface * bus;
colorful_gpu_dev_id dev;
std::string name;
};

View file

@ -17,9 +17,8 @@ void DetectColorfulTuringGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_ad
{
if(bus->port_id == 1)
{
ColorfulTuringGPUController* controller = new ColorfulTuringGPUController(bus, i2c_addr);
ColorfulTuringGPUController* controller = new ColorfulTuringGPUController(bus, i2c_addr, name);
RGBController_ColorfulTuringGPU* rgb_controller = new RGBController_ColorfulTuringGPU(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}

View file

@ -24,7 +24,8 @@
RGBController_ColorfulTuringGPU::RGBController_ColorfulTuringGPU(ColorfulTuringGPUController * colorful_gpu_ptr)
{
controller = colorful_gpu_ptr;
name = "Colorful GPU Device";
name = controller->GetDeviceName();
vendor = "Colorful";
type = DEVICE_TYPE_GPU;
description = name;