diff --git a/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2Controller.cpp b/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2Controller.cpp index 46eef684..a75cb361 100644 --- a/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2Controller.cpp +++ b/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2Controller.cpp @@ -15,10 +15,11 @@ using namespace std::chrono_literals; -MSIGPUv2Controller::MSIGPUv2Controller(i2c_smbus_interface* bus, msi_gpu_dev_id dev) +MSIGPUv2Controller::MSIGPUv2Controller(i2c_smbus_interface* bus, msi_gpu_dev_id dev, std::string dev_name) { - this->bus = bus; - this->dev = dev; + this->bus = bus; + this->dev = dev; + this->name = dev_name; } MSIGPUv2Controller::~MSIGPUv2Controller() @@ -36,6 +37,11 @@ std::string MSIGPUv2Controller::GetDeviceLocation() return("I2C: " + return_string); } +std::string MSIGPUv2Controller::GetDeviceName() +{ + return(name); +} + void MSIGPUv2Controller::SetRGB1(unsigned char red, unsigned char green, unsigned char blue) { MSIGPURegisterWrite(MSI_GPU_V2_REG_R1, red); diff --git a/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2Controller.h b/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2Controller.h index fac10970..bc1a7ad1 100644 --- a/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2Controller.h +++ b/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2Controller.h @@ -75,10 +75,11 @@ enum class MSIGPUv2Controller { public: - MSIGPUv2Controller(i2c_smbus_interface* bus, msi_gpu_dev_id dev); + MSIGPUv2Controller(i2c_smbus_interface* bus, msi_gpu_dev_id dev, std::string dev_name); ~MSIGPUv2Controller(); std::string GetDeviceLocation(); + std::string GetDeviceName(); void SetRGB1(unsigned char red, unsigned char green, unsigned char blue); void SetRGB1V2(unsigned char red, unsigned char green, unsigned char blue); @@ -95,4 +96,5 @@ public: private: i2c_smbus_interface * bus; msi_gpu_dev_id dev; + std::string name; }; diff --git a/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2ControllerDetect.cpp b/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2ControllerDetect.cpp index 76eb9017..e33ca3b7 100644 --- a/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2ControllerDetect.cpp +++ b/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2ControllerDetect.cpp @@ -30,13 +30,11 @@ void DetectMSIGPUv2Controllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const return; } - int msi_gpu_id = bus->pci_subsystem_device | bus->pci_device << 16; - MSIGPUv2Controller* controller = new MSIGPUv2Controller(bus, i2c_addr); - RGBController_MSIGPUv2* rgb_controller = new RGBController_MSIGPUv2(controller, msi_gpu_id); - rgb_controller->name = name; - ResourceManager::get()->RegisterRGBController(rgb_controller); - LOG_TRACE("MSI GPU Controler using ITE9 chip"); + int msi_gpu_id = bus->pci_subsystem_device | bus->pci_device << 16; + MSIGPUv2Controller* controller = new MSIGPUv2Controller(bus, i2c_addr, name); + RGBController_MSIGPUv2* rgb_controller = new RGBController_MSIGPUv2(controller, msi_gpu_id); + ResourceManager::get()->RegisterRGBController(rgb_controller); } /* DetectMSIGPUv2Controllers() */ REGISTER_I2C_PCI_DETECTOR("MSI GeForce RTX 4060 Gaming X", DetectMSIGPUv2Controllers, NVIDIA_VEN, NVIDIA_RTX4060_DEV, MSI_SUB_VEN, MSI_RTX4060_GAMING_X_8G_SUB_DEV, 0x68); diff --git a/Controllers/MSIGPUController/MSIGPUv2Controller/RGBController_MSIGPUv2.cpp b/Controllers/MSIGPUController/MSIGPUv2Controller/RGBController_MSIGPUv2.cpp index 4eb0b11c..17903a29 100644 --- a/Controllers/MSIGPUController/MSIGPUv2Controller/RGBController_MSIGPUv2.cpp +++ b/Controllers/MSIGPUController/MSIGPUv2Controller/RGBController_MSIGPUv2.cpp @@ -25,18 +25,17 @@ static const unsigned char speed_values[3] = { 0x04, 0x02, 0x01 }; @comment \*-------------------------------------------------------------------*/ -RGBController_MSIGPUv2::RGBController_MSIGPUv2(MSIGPUv2Controller * msi_gpu_ptr, int msi_gpu_id) +RGBController_MSIGPUv2::RGBController_MSIGPUv2(MSIGPUv2Controller * controller_ptr, int msi_gpu_id) { - msi_gpu = msi_gpu_ptr; + controller = controller_ptr; - name = "MSI GPU Device"; - vendor = "MSI"; - type = DEVICE_TYPE_GPU; - description = name; - location = msi_gpu->GetDeviceLocation(); + name = controller->GetDeviceName(); + vendor = "MSI"; + type = DEVICE_TYPE_GPU; + description = "MSI GPU V2 Device"; + location = controller->GetDeviceLocation(); mode Off; - Off.name = "Off"; Off.value = MSI_GPU_V2_MODE_OFF; Off.flags = MODE_FLAG_MANUAL_SAVE; @@ -294,7 +293,7 @@ RGBController_MSIGPUv2::RGBController_MSIGPUv2(MSIGPUv2Controller * msi_gpu_ptr, RGBController_MSIGPUv2::~RGBController_MSIGPUv2() { - delete msi_gpu; + delete controller; } void RGBController_MSIGPUv2::SetupZones() @@ -360,62 +359,62 @@ void RGBController_MSIGPUv2::DeviceUpdateAll(const mode& current_mode) { if(current_mode.direction == MODE_DIRECTION_LEFT) { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_LEFT | MSI_GPU_V2_CONTROL_NON_RGBMODE); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_LEFT | MSI_GPU_V2_CONTROL_NON_RGBMODE); } else { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_RIGHT | MSI_GPU_V2_CONTROL_NON_RGBMODE); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_RIGHT | MSI_GPU_V2_CONTROL_NON_RGBMODE); } - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); - msi_gpu->SetRGB1V2(RGBGetRValue(current_mode.colors[0]), RGBGetGValue(current_mode.colors[0]), RGBGetBValue(current_mode.colors[0])); - msi_gpu->SetRGB2V2(RGBGetRValue(current_mode.colors[1]), RGBGetGValue(current_mode.colors[1]), RGBGetBValue(current_mode.colors[1])); - msi_gpu->SetRGB3V2(RGBGetRValue(current_mode.colors[2]), RGBGetGValue(current_mode.colors[2]), RGBGetBValue(current_mode.colors[2])); + controller->SetRGB1V2(RGBGetRValue(current_mode.colors[0]), RGBGetGValue(current_mode.colors[0]), RGBGetBValue(current_mode.colors[0])); + controller->SetRGB2V2(RGBGetRValue(current_mode.colors[1]), RGBGetGValue(current_mode.colors[1]), RGBGetBValue(current_mode.colors[1])); + controller->SetRGB3V2(RGBGetRValue(current_mode.colors[2]), RGBGetGValue(current_mode.colors[2]), RGBGetBValue(current_mode.colors[2])); } else { if(current_mode.direction == MODE_DIRECTION_LEFT) { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_LEFT); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_LEFT); } else { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_RIGHT); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_RIGHT); } - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); } break; case MSI_GPU_V2_MODE_MAGIC: if(current_mode.flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR) { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_NON_RGBMODE); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_NON_RGBMODE); - msi_gpu->SetRGB1V2(RGBGetRValue(current_mode.colors[0]), RGBGetGValue(current_mode.colors[0]), RGBGetBValue(current_mode.colors[0])); - msi_gpu->SetRGB2V2(RGBGetRValue(current_mode.colors[1]), RGBGetGValue(current_mode.colors[1]), RGBGetBValue(current_mode.colors[1])); - msi_gpu->SetRGB3V2(RGBGetRValue(current_mode.colors[2]), RGBGetGValue(current_mode.colors[2]), RGBGetBValue(current_mode.colors[2])); + controller->SetRGB1V2(RGBGetRValue(current_mode.colors[0]), RGBGetGValue(current_mode.colors[0]), RGBGetBValue(current_mode.colors[0])); + controller->SetRGB2V2(RGBGetRValue(current_mode.colors[1]), RGBGetGValue(current_mode.colors[1]), RGBGetBValue(current_mode.colors[1])); + controller->SetRGB3V2(RGBGetRValue(current_mode.colors[2]), RGBGetGValue(current_mode.colors[2]), RGBGetBValue(current_mode.colors[2])); } else { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_RIGHT); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_CONTROL, MSI_GPU_V2_CONTROL_DIRECTION_RIGHT); } break; case MSI_GPU_V2_MODE_BREATHING: case MSI_GPU_V2_MODE_FADEIN: - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); - msi_gpu->SetRGB1V2(RGBGetRValue(current_mode.colors[0]), RGBGetGValue(current_mode.colors[0]), RGBGetBValue(current_mode.colors[0])); - msi_gpu->SetRGB2V2(RGBGetRValue(current_mode.colors[1]), RGBGetGValue(current_mode.colors[1]), RGBGetBValue(current_mode.colors[1])); + controller->SetRGB1V2(RGBGetRValue(current_mode.colors[0]), RGBGetGValue(current_mode.colors[0]), RGBGetBValue(current_mode.colors[0])); + controller->SetRGB2V2(RGBGetRValue(current_mode.colors[1]), RGBGetGValue(current_mode.colors[1]), RGBGetBValue(current_mode.colors[1])); break; case MSI_GPU_V2_MODE_FLOWING: @@ -427,36 +426,36 @@ void RGBController_MSIGPUv2::DeviceUpdateAll(const mode& current_mode) case MSI_GPU_V2_MODE_RHYTHM: case MSI_GPU_V2_MODE_STACK: case MSI_GPU_V2_MODE_METEOR: - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); - msi_gpu->SetRGB1(RGBGetRValue(colors[0]), RGBGetGValue(colors[0]), RGBGetBValue(colors[0])); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); + controller->SetRGB1(RGBGetRValue(colors[0]), RGBGetGValue(colors[0]), RGBGetBValue(colors[0])); break; case MSI_GPU_V2_MODE_STREAMING: case MSI_GPU_V2_MODE_LIGHTNING: case MSI_GPU_V2_MODE_OFF: - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); break; default: - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); - msi_gpu->SetMode(MSI_GPU_V2_MODE_OFF); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_UNKNOWN, 0x00); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_MODE, MSI_GPU_V2_MODE_IDLE); + controller->SetMode(MSI_GPU_V2_MODE_OFF); } if(current_mode.flags & MODE_FLAG_HAS_BRIGHTNESS) { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_BRIGHTNESS, MSI_GPU_V2_BRIGHTNESS_MULTI * modes[active_mode].brightness); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_BRIGHTNESS, MSI_GPU_V2_BRIGHTNESS_MULTI * modes[active_mode].brightness); if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED) { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_V2_REG_SPEED, speed_values[current_mode.speed]); + controller->MSIGPURegisterWrite(MSI_GPU_V2_REG_SPEED, speed_values[current_mode.speed]); } } - msi_gpu->SetMode(current_mode.value); + controller->SetMode(current_mode.value); } @@ -485,5 +484,5 @@ void RGBController_MSIGPUv2::DeviceUpdateMode() void RGBController_MSIGPUv2::DeviceSaveMode() { - msi_gpu->Save(); + controller->Save(); } diff --git a/Controllers/MSIGPUController/MSIGPUv2Controller/RGBController_MSIGPUv2.h b/Controllers/MSIGPUController/MSIGPUv2Controller/RGBController_MSIGPUv2.h index dbe952cc..39f98611 100644 --- a/Controllers/MSIGPUController/MSIGPUv2Controller/RGBController_MSIGPUv2.h +++ b/Controllers/MSIGPUController/MSIGPUv2Controller/RGBController_MSIGPUv2.h @@ -18,7 +18,7 @@ class RGBController_MSIGPUv2 : public RGBController { public: - RGBController_MSIGPUv2(MSIGPUv2Controller* msi_gpu_ptr, int msi_gpu_id); + RGBController_MSIGPUv2(MSIGPUv2Controller* controller_ptr, int msi_gpu_id); ~RGBController_MSIGPUv2(); void SetupZones(); @@ -32,6 +32,7 @@ public: void DeviceSaveMode(); private: - MSIGPUv2Controller* msi_gpu; + MSIGPUv2Controller* controller; + void DeviceUpdateAll(const mode& current_mode); };