diff --git a/Controllers/ColorfulGPUController/ColorfulGPUController.cpp b/Controllers/ColorfulGPUController/ColorfulGPUController.cpp new file mode 100644 index 00000000..f7e3a3fa --- /dev/null +++ b/Controllers/ColorfulGPUController/ColorfulGPUController.cpp @@ -0,0 +1,44 @@ +#include "ColorfulGPUController.h" +#include + +ColorfulGPUController::ColorfulGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev) +{ + this->bus = bus; + this->dev = dev; +} + +ColorfulGPUController::~ColorfulGPUController() +{ + +} + +std::string ColorfulGPUController::GetDeviceLocation() +{ + std::string return_string(bus->device_name); + char addr[5]; + snprintf(addr, 5, "0x%02X", dev); + return_string.append(", address "); + return_string.append(addr); + return("I2C: " + return_string); +} + +void ColorfulGPUController::SetDirect(RGBColor color) +{ + uint8_t r = RGBGetRValue(color); + uint8_t g = RGBGetGValue(color); + uint8_t b = RGBGetBValue(color); + + uint8_t data_pkt[COLORFUL_PACKET_LENGTH] = { 0xAA, 0xEF, 0x12, 0x03, 0x01, 0xFF, r, g, b}; + + int crc = 0; + + for (int i = 0; i < COLORFUL_PACKET_LENGTH - 2; ++i) + { + crc += data_pkt[i]; + } + + data_pkt[COLORFUL_PACKET_LENGTH - 2] = crc & 0xFF; + data_pkt[COLORFUL_PACKET_LENGTH - 1] = crc >> 8; + + bus->i2c_write_block(dev, COLORFUL_PACKET_LENGTH, data_pkt); +} diff --git a/Controllers/ColorfulGPUController/ColorfulGPUController.h b/Controllers/ColorfulGPUController/ColorfulGPUController.h new file mode 100644 index 00000000..ed5c9948 --- /dev/null +++ b/Controllers/ColorfulGPUController/ColorfulGPUController.h @@ -0,0 +1,24 @@ +#include +#include "i2c_smbus.h" +#include "RGBController.h" + +#pragma once + +typedef unsigned char colorful_gpu_dev_id; + +#define COLORFUL_PACKET_LENGTH 11 + +class ColorfulGPUController +{ +public: + ColorfulGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev); + ~ColorfulGPUController(); + + std::string GetDeviceLocation(); + void SetDirect(RGBColor color); + + +private: + i2c_smbus_interface * bus; + colorful_gpu_dev_id dev; +}; diff --git a/Controllers/ColorfulGPUController/ColorfulGPUControllerDetect.cpp b/Controllers/ColorfulGPUController/ColorfulGPUControllerDetect.cpp new file mode 100644 index 00000000..a1be8282 --- /dev/null +++ b/Controllers/ColorfulGPUController/ColorfulGPUControllerDetect.cpp @@ -0,0 +1,40 @@ +#include "Detector.h" +#include "ColorfulGPUController.h" +#include "RGBController.h" +#include "RGBController_ColorfulGPU.h" +#include "i2c_smbus.h" +#include "pci_ids.h" +#include +#include +#include + +bool TestForColorfulGPU(i2c_smbus_interface* bus, uint8_t i2c_addr) +{ + int pktsz; + const int read_sz = 0x40; + const int write_sz = 6; + + uint8_t data_pkt[write_sz] = { 0xAA, 0xEF, 0x81, 0x02, 0x1C, 0x02}; + bus->i2c_write_block(i2c_addr, write_sz, data_pkt); + + uint8_t read_pkt[read_sz] = {}; + pktsz = read_sz; + + int res = bus->i2c_read_block(i2c_addr, &pktsz, read_pkt); + + return res == 0 && (read_pkt[0] == 0xAA && read_pkt[1] == 0xEF && read_pkt[2] == 0x81); +} + +void DetectColorfulGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const std::string& name) +{ + if(TestForColorfulGPU(bus, i2c_addr)) + { + ColorfulGPUController* controller = new ColorfulGPUController(bus, i2c_addr); + RGBController_ColorfulGPU* rgb_controller = new RGBController_ColorfulGPU(controller); + rgb_controller->name = name; + + ResourceManager::get()->RegisterRGBController(rgb_controller); + } +} + +REGISTER_I2C_PCI_DETECTOR("iGame GeForce RTX 3070 Advanced OC-V", DetectColorfulGPUControllers, NVIDIA_VEN, NVIDIA_RTX3070_DEV, COLORFUL_SUB_VEN, COLORFUL_IGAME_RTX_3070_ADVANCED_OCV, 0x61); diff --git a/Controllers/ColorfulGPUController/RGBController_ColorfulGPU.cpp b/Controllers/ColorfulGPUController/RGBController_ColorfulGPU.cpp new file mode 100644 index 00000000..56593ba4 --- /dev/null +++ b/Controllers/ColorfulGPUController/RGBController_ColorfulGPU.cpp @@ -0,0 +1,82 @@ +#include "RGBController_ColorfulGPU.h" +#include + +/**------------------------------------------------------------------*\ + @name Colorful GPU + @category GPU + @type I2C + @save :x: + @direct :white_check_mark: + @effects :x: + @detectors DetectColorfulGPUControllers + @comment This card only supports direct mode +\*-------------------------------------------------------------------*/ + +RGBController_ColorfulGPU::RGBController_ColorfulGPU(ColorfulGPUController * colorful_gpu_ptr) +{ + controller = colorful_gpu_ptr; + name = "Colorful GPU Device"; + vendor = "Colorful"; + type = DEVICE_TYPE_GPU; + description = name; + location = controller->GetDeviceLocation(); + + mode Direct; + Direct.name = "Direct"; + Direct.value = 0; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Direct); + + SetupZones(); + +} + +RGBController_ColorfulGPU::~RGBController_ColorfulGPU() +{ + delete controller; +} + +void RGBController_ColorfulGPU::SetupZones() +{ + zone new_zone; + + new_zone.name = "GPU"; + new_zone.type = ZONE_TYPE_LINEAR; + new_zone.leds_min = 1; + new_zone.leds_max = 1; + new_zone.leds_count = 1; + new_zone.matrix_map = nullptr; + + zones.emplace_back(new_zone); + + leds.resize(new_zone.leds_count); + leds[0].name = "GPU LED"; + + SetupColors(); +} + +void RGBController_ColorfulGPU::ResizeZone(int /*zone*/, int /*new_size*/) +{ + +} + +void RGBController_ColorfulGPU::DeviceUpdateLEDs() +{ + controller->SetDirect(colors[0]); +} + +void RGBController_ColorfulGPU::UpdateZoneLEDs(int /*zone*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_ColorfulGPU::UpdateSingleLED(int /*led*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_ColorfulGPU::DeviceUpdateMode() +{ + DeviceUpdateLEDs(); +} diff --git a/Controllers/ColorfulGPUController/RGBController_ColorfulGPU.h b/Controllers/ColorfulGPUController/RGBController_ColorfulGPU.h new file mode 100644 index 00000000..01d335c7 --- /dev/null +++ b/Controllers/ColorfulGPUController/RGBController_ColorfulGPU.h @@ -0,0 +1,26 @@ +#pragma once + +#include "RGBController.h" +#include "ColorfulGPUController.h" + +class RGBController_ColorfulGPU : public RGBController +{ +public: + RGBController_ColorfulGPU(ColorfulGPUController* colorful_gpu_ptr); + ~RGBController_ColorfulGPU(); + + void SetupZones(); + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void DeviceUpdateMode(); + +private: + ColorfulGPUController* controller; + +}; + + diff --git a/OpenRGB.pro b/OpenRGB.pro index 735b57a7..a96ce2a4 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -295,6 +295,8 @@ HEADERS += Controllers/AsusLegacyUSBController/RGBController_AsusStrixClaw.h \ Controllers/BlinkyTapeController/BlinkyTapeController.h \ Controllers/BlinkyTapeController/RGBController_BlinkyTape.h \ + Controllers/ColorfulGPUController/ColorfulGPUController.h \ + Controllers/ColorfulGPUController/RGBController_ColorfulGPU.h \ Controllers/CoolerMasterController/CMARGBcontroller.h \ Controllers/CoolerMasterController/CMARGBGen2A1controller.h \ Controllers/CoolerMasterController/CMMKController.h \ @@ -793,6 +795,9 @@ SOURCES += Controllers/BlinkyTapeController/BlinkyTapeController.cpp \ Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp \ Controllers/BlinkyTapeController/RGBController_BlinkyTape.cpp \ + Controllers/ColorfulGPUController/ColorfulGPUController.cpp \ + Controllers/ColorfulGPUController/ColorfulGPUControllerDetect.cpp \ + Controllers/ColorfulGPUController/RGBController_ColorfulGPU.cpp \ Controllers/CoolerMasterController/CMARGBcontroller.cpp \ Controllers/CoolerMasterController/CMARGBGen2A1controller.cpp \ Controllers/CoolerMasterController/CMMKController.cpp \ diff --git a/pci_ids/pci_ids.h b/pci_ids/pci_ids.h index 63dd6b14..7e118033 100644 --- a/pci_ids/pci_ids.h +++ b/pci_ids/pci_ids.h @@ -1,4 +1,4 @@ -/*---------------------------------------------------------*\ +/*---------------------------------------------------------*\ | PCI Vendor IDs | \*---------------------------------------------------------*/ #define AMD_VEN 0x1022 @@ -102,6 +102,7 @@ \*---------------------------------------------------------*/ #define ASROCK_SUB_VEN 0x1849 #define ASUS_SUB_VEN 0x1043 +#define COLORFUL_SUB_VEN 0x7377 #define EVGA_SUB_VEN 0x3842 #define GALAX_SUB_VEN 0x1B4C #define GAINWARD_SUB_VEN 0x10B0 @@ -224,6 +225,11 @@ #define ASUS_TUF_RX_6900XT_O16G_GAMING 0x04FA #define ASUS_TUF_RTX_4090_O24G_OC_GAMING 0x889A +/*-----------------------------------------------------*\ +| Colorful Sub-Device IDs | +\*-----------------------------------------------------*/ +#define COLORFUL_IGAME_RTX_3070_ADVANCED_OCV 0x140A + /*-----------------------------------------------------*\ | EVGA Sub-Device IDs | \*-----------------------------------------------------*/