Add support for Colorful Turing RTX 2070

This commit is contained in:
Lucas Mindêllo de Andrade 2023-05-28 22:26:50 +00:00 committed by Adam Honse
parent a67cf011d5
commit 10047188ad
7 changed files with 205 additions and 0 deletions

View file

@ -0,0 +1,44 @@
#include "ColorfulTuringGPUController.h"
#include <cstring>
ColorfulTuringGPUController::ColorfulTuringGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev)
{
this->bus = bus;
this->dev = dev;
}
ColorfulTuringGPUController::~ColorfulTuringGPUController()
{
}
std::string ColorfulTuringGPUController::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 ColorfulTuringGPUController::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] = { 0x88, 0x02, 0x32, 0x02, r, g, b};
int crc = 1;
for(int i = 0; i < COLORFUL_PACKET_LENGTH - 1; ++i)
{
crc += data_pkt[i];
}
crc &= 0xFF;
crc = 256-crc;
data_pkt[COLORFUL_PACKET_LENGTH - 1] = crc & 0xFF;
bus->i2c_write_block(dev, COLORFUL_PACKET_LENGTH, data_pkt);
}

View file

@ -0,0 +1,24 @@
#include <string>
#include "i2c_smbus.h"
#include "RGBController.h"
#pragma once
typedef unsigned char colorful_gpu_dev_id;
#define COLORFUL_PACKET_LENGTH 8
class ColorfulTuringGPUController
{
public:
ColorfulTuringGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev);
~ColorfulTuringGPUController();
std::string GetDeviceLocation();
void SetDirect(RGBColor color);
private:
i2c_smbus_interface * bus;
colorful_gpu_dev_id dev;
};

View file

@ -0,0 +1,23 @@
#include "Detector.h"
#include "ColorfulTuringGPUController.h"
#include "RGBController.h"
#include "RGBController_ColorfulTuringGPU.h"
#include "i2c_smbus.h"
#include "pci_ids.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
void DetectColorfulTuringGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const std::string& name)
{
if(bus->port_id == 1)
{
ColorfulTuringGPUController* controller = new ColorfulTuringGPUController(bus, i2c_addr);
RGBController_ColorfulTuringGPU* rgb_controller = new RGBController_ColorfulTuringGPU(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_I2C_PCI_DETECTOR("iGame GeForce RTX 2070 SUPER Advanced OC-V", DetectColorfulTuringGPUControllers, NVIDIA_VEN, NVIDIA_RTX2070S_OC_DEV, COLORFUL_SUB_VEN, COLORFUL_IGAME_RTX_2070_SUPER_ADVANCED_OCV, 0x50);

View file

@ -0,0 +1,82 @@
#include "RGBController_ColorfulTuringGPU.h"
#include <array>
/**------------------------------------------------------------------*\
@name Colorful GPU
@category GPU
@type I2C
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectColorfulTuringGPUControllers
@comment This card only supports direct mode
\*-------------------------------------------------------------------*/
RGBController_ColorfulTuringGPU::RGBController_ColorfulTuringGPU(ColorfulTuringGPUController * 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_ColorfulTuringGPU::~RGBController_ColorfulTuringGPU()
{
delete controller;
}
void RGBController_ColorfulTuringGPU::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_ColorfulTuringGPU::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_ColorfulTuringGPU::DeviceUpdateLEDs()
{
controller->SetDirect(colors[0]);
}
void RGBController_ColorfulTuringGPU::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_ColorfulTuringGPU::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_ColorfulTuringGPU::DeviceUpdateMode()
{
DeviceUpdateLEDs();
}

View file

@ -0,0 +1,26 @@
#pragma once
#include "RGBController.h"
#include "ColorfulTuringGPUController.h"
class RGBController_ColorfulTuringGPU : public RGBController
{
public:
RGBController_ColorfulTuringGPU(ColorfulTuringGPUController* colorful_gpu_ptr);
~RGBController_ColorfulTuringGPU();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
ColorfulTuringGPUController* controller;
};

View file

@ -333,6 +333,8 @@ HEADERS +=
Controllers/CherryKeyboardController/RGBController_CherryKeyboard.h \
Controllers/ColorfulGPUController/ColorfulGPUController.h \
Controllers/ColorfulGPUController/RGBController_ColorfulGPU.h \
Controllers/ColorfulTuringGPUController/ColorfulTuringGPUController.h \
Controllers/ColorfulTuringGPUController/RGBController_ColorfulTuringGPU.h \
Controllers/CoolerMasterController/CMARGBcontroller.h \
Controllers/CoolerMasterController/CMARGBGen2A1controller.h \
Controllers/CoolerMasterController/CMMKController.h \
@ -908,6 +910,9 @@ SOURCES +=
Controllers/ColorfulGPUController/ColorfulGPUController.cpp \
Controllers/ColorfulGPUController/ColorfulGPUControllerDetect.cpp \
Controllers/ColorfulGPUController/RGBController_ColorfulGPU.cpp \
Controllers/ColorfulTuringGPUController/ColorfulTuringGPUController.cpp \
Controllers/ColorfulTuringGPUController/ColorfulTuringGPUControllerDetect.cpp \
Controllers/ColorfulTuringGPUController/RGBController_ColorfulTuringGPU.cpp \
Controllers/CoolerMasterController/CMARGBcontroller.cpp \
Controllers/CoolerMasterController/CMARGBGen2A1controller.cpp \
Controllers/CoolerMasterController/CMMKController.cpp \

View file

@ -269,6 +269,7 @@
/*-----------------------------------------------------*\
| Colorful Sub-Device IDs |
\*-----------------------------------------------------*/
#define COLORFUL_IGAME_RTX_2070_SUPER_ADVANCED_OCV 0X1401
#define COLORFUL_IGAME_RTX_3060_ULTRAW_OC_12G 0x150A
#define COLORFUL_IGAME_RTX_3060_ULTRAW_OC_12G_2 0x1501
#define COLORFUL_IGAME_RTX_3070_ADVANCED_OCV 0x140A