From 9b6e24947da7a1cc2a4acb40597c079609b03be0 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 12 Jul 2020 16:29:34 -0500 Subject: [PATCH] Code style cleanup for MSI GPU controller --- .../MSIGPUControllerDetect.cpp | 11 +++++++--- RGBController/RGBController_MSIGPU.cpp | 21 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Controllers/MSIGPUController/MSIGPUControllerDetect.cpp b/Controllers/MSIGPUController/MSIGPUControllerDetect.cpp index 56dd4de5..fc1d2ff2 100644 --- a/Controllers/MSIGPUController/MSIGPUControllerDetect.cpp +++ b/Controllers/MSIGPUController/MSIGPUControllerDetect.cpp @@ -26,13 +26,16 @@ bool IsMSIGPUController(i2c_smbus_interface* bus) bool pass = false; if (bus->port_id != 1) + { return(pass); + } // MSI RTX 2080S Gaming X Trio if (bus->pci_device == 0x1e81 && bus->pci_vendor == 0x10de && bus->pci_subsystem_device == 0xc724 && - bus->pci_subsystem_vendor == 0x1462) { + bus->pci_subsystem_vendor == 0x1462) + { pass = true; } @@ -40,7 +43,8 @@ bool IsMSIGPUController(i2c_smbus_interface* bus) if (bus->pci_device == 0x1e84 && bus->pci_vendor == 0x10de && bus->pci_subsystem_device == 0xc726 && - bus->pci_subsystem_vendor == 0x1462) { + bus->pci_subsystem_vendor == 0x1462) + { pass = true; } @@ -48,7 +52,8 @@ bool IsMSIGPUController(i2c_smbus_interface* bus) if (bus->pci_device == 0x1e07 && bus->pci_vendor == 0x10de && bus->pci_subsystem_device == 0x3717 && - bus->pci_subsystem_vendor == 0x1462) { + bus->pci_subsystem_vendor == 0x1462) + { pass = true; } diff --git a/RGBController/RGBController_MSIGPU.cpp b/RGBController/RGBController_MSIGPU.cpp index dadd472e..c8518755 100644 --- a/RGBController/RGBController_MSIGPU.cpp +++ b/RGBController/RGBController_MSIGPU.cpp @@ -8,7 +8,7 @@ #include "RGBController_MSIGPU.h" static unsigned char brightness_values[] = { 0x14, 0x28, 0x3c, 0x50, 0x64 }; -static unsigned char speed_values[] = { 0x04, 0x02, 0x01 }; +static unsigned char speed_values[] = { 0x04, 0x02, 0x01 }; int RGBController_MSIGPU::GetDeviceMode() { @@ -274,17 +274,30 @@ void RGBController_MSIGPU::ResizeZone(int /*zone*/, int /*new_size*/) void RGBController_MSIGPU::DeviceUpdateLEDs() { if (modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS) + { msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_BRIGHTNESS, brightness_values[4]); // how to access brightness value? + } + if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED) + { msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_SPEED, speed_values[modes[active_mode].speed]); + } + msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_UNKNOWN, 0x00); - if (modes[active_mode].flags & MODE_FLAG_HAS_PER_LED_COLOR) { - if (modes[active_mode].value == MSI_GPU_MODE_FADEIN) { + + if (modes[active_mode].flags & MODE_FLAG_HAS_PER_LED_COLOR) + { + if (modes[active_mode].value == MSI_GPU_MODE_FADEIN) + { msi_gpu->SetRGB2(RGBGetRValue(colors[1]), RGBGetGValue(colors[1]), RGBGetBValue(colors[1])); msi_gpu->SetRGB3(RGBGetRValue(colors[2]), RGBGetGValue(colors[2]), RGBGetBValue(colors[2])); - } else + } + else + { msi_gpu->SetRGB1(RGBGetRValue(colors[0]), RGBGetGValue(colors[0]), RGBGetBValue(colors[0])); + } } + msi_gpu->SetMode(modes[active_mode].value); }