Implemented ColorfulGPUController to support iGame 3070. Closes #2841
This commit is contained in:
parent
4d4c18f1ef
commit
3b9f06b10b
7 changed files with 228 additions and 1 deletions
44
Controllers/ColorfulGPUController/ColorfulGPUController.cpp
Normal file
44
Controllers/ColorfulGPUController/ColorfulGPUController.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#include "ColorfulGPUController.h"
|
||||
#include <cstring>
|
||||
|
||||
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);
|
||||
}
|
||||
24
Controllers/ColorfulGPUController/ColorfulGPUController.h
Normal file
24
Controllers/ColorfulGPUController/ColorfulGPUController.h
Normal 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 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;
|
||||
};
|
||||
|
|
@ -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 <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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);
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
#include "RGBController_ColorfulGPU.h"
|
||||
#include <array>
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@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();
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue