Skip to content

Commit 555fb7b

Browse files
515orestisCalcProgrammer1
authored andcommitted
add support for manli RTX 4090 gallardo issue #4168
1 parent 7a4eb4d commit 555fb7b

6 files changed

Lines changed: 497 additions & 0 deletions

File tree

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*---------------------------------------------------------*\
2+
| ManliGPUController.cpp |
3+
| |
4+
| Driver for Manli GPU RGB controllers |
5+
| |
6+
| Based on ZotacV2GPUController |
7+
| Adapted for Manli RTX 4090 Gallardo |
8+
| |
9+
| This file is part of the OpenRGB project |
10+
| SPDX-License-Identifier: GPL-2.0-or-later |
11+
\*---------------------------------------------------------*/
12+
13+
#include "ManliGPUController.h"
14+
15+
ManliGPUController::ManliGPUController(i2c_smbus_interface* bus, u8 dev, std::string dev_name)
16+
{
17+
this->bus = bus;
18+
this->dev = dev;
19+
this->name = dev_name;
20+
21+
if(dev)
22+
{
23+
ReadVersion();
24+
}
25+
}
26+
27+
ManliGPUController::~ManliGPUController()
28+
{
29+
}
30+
31+
std::string ManliGPUController::GetDeviceLocation()
32+
{
33+
std::string return_string(bus->device_name);
34+
char addr[5];
35+
snprintf(addr, 5, "0x%02X", dev);
36+
return_string.append(", address ");
37+
return_string.append(addr);
38+
return ("I2C: " + return_string);
39+
}
40+
41+
std::string ManliGPUController::GetName()
42+
{
43+
return(name);
44+
}
45+
46+
std::string ManliGPUController::GetVersion()
47+
{
48+
return(version);
49+
}
50+
51+
bool ManliGPUController::ReadVersion()
52+
{
53+
u8 data_pkt[] = { MANLI_GPU_REG_RGB, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
54+
if(bus->i2c_write_block(dev, sizeof(data_pkt), data_pkt) < 0)
55+
{
56+
return false;
57+
}
58+
59+
u8 rdata_pkt[I2C_SMBUS_BLOCK_MAX] = { 0x00 };
60+
int rdata_len = sizeof(rdata_pkt);
61+
if(bus->i2c_read_block(dev, &rdata_len, rdata_pkt) < 0)
62+
{
63+
return false;
64+
}
65+
66+
version = std::string((char*)rdata_pkt);
67+
return true;
68+
}
69+
70+
bool ManliGPUController::TurnOnOff(bool on)
71+
{
72+
ManliGPUZone zoneConfig;
73+
return SendCommand(on, zoneConfig);
74+
}
75+
76+
bool ManliGPUController::SetMode(ManliGPUZone zoneConfig)
77+
{
78+
return SendCommand(true, zoneConfig);
79+
}
80+
81+
bool ManliGPUController::SendCommand(bool on, ManliGPUZone zoneConfig)
82+
{
83+
/*---------------------------------------------------------*\
84+
| Color Cycle: Uses breathing mode (0x01) with flag 0x07 |
85+
| This cycles through colors with brightness and speed |
86+
\*---------------------------------------------------------*/
87+
if(zoneConfig.mode == MANLI_GPU_MODE_COLOR_CYCLE)
88+
{
89+
u8 data_pkt[30] = { 0x00 };
90+
data_pkt[0] = on ? (u8)0x01 : (u8)0x00;
91+
data_pkt[6] = 0x01; // mode = breathing
92+
data_pkt[7] = 0x00; // R
93+
data_pkt[8] = 0x00; // G
94+
data_pkt[9] = 0x00; // B
95+
data_pkt[10] = (u8)zoneConfig.speed;
96+
data_pkt[11] = (u8)zoneConfig.brightness;
97+
data_pkt[13] = 0x07; // color cycle flag
98+
99+
if(bus->i2c_smbus_write_i2c_block_data(dev, MANLI_GPU_REG_RGB, sizeof(data_pkt), data_pkt) < 0)
100+
{
101+
return false;
102+
}
103+
return true;
104+
}
105+
/*---------------------------------------------------------*\
106+
| Standard modes (Static, Breathing, Wave, Strobing, Rainbow)|
107+
\*---------------------------------------------------------*/
108+
else
109+
{
110+
u8 data_pkt[30] = { 0x00 };
111+
data_pkt[0] = on ? (u8)0x01 : (u8)0x00;
112+
data_pkt[6] = (u8)zoneConfig.mode;
113+
data_pkt[7] = (u8)RGBGetRValue(zoneConfig.color1);
114+
data_pkt[8] = (u8)RGBGetGValue(zoneConfig.color1);
115+
data_pkt[9] = (u8)RGBGetBValue(zoneConfig.color1);
116+
data_pkt[10] = (u8)zoneConfig.speed;
117+
data_pkt[11] = (u8)zoneConfig.brightness;
118+
119+
if(bus->i2c_smbus_write_i2c_block_data(dev, MANLI_GPU_REG_RGB, sizeof(data_pkt), data_pkt) < 0)
120+
{
121+
return false;
122+
}
123+
return true;
124+
}
125+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*---------------------------------------------------------*\
2+
| ManliGPUController.h |
3+
| |
4+
| Driver for Manli GPU RGB controllers |
5+
| |
6+
| Based on ZotacV2GPUController |
7+
| Adapted for Manli RTX 4090 Gallardo |
8+
| |
9+
| This file is part of the OpenRGB project |
10+
| SPDX-License-Identifier: GPL-2.0-or-later |
11+
\*---------------------------------------------------------*/
12+
13+
#pragma once
14+
15+
#include <string>
16+
#include "i2c_smbus.h"
17+
#include "RGBController.h"
18+
19+
enum
20+
{
21+
MANLI_GPU_REG_RGB = 0xA0,
22+
};
23+
24+
enum
25+
{
26+
MANLI_GPU_MODE_STATIC = 0x00, // Static color
27+
MANLI_GPU_MODE_BREATHING = 0x01, // Breathing effect
28+
MANLI_GPU_MODE_WAVE = 0x02, // Wave effect (no brightness - HW limitation)
29+
MANLI_GPU_MODE_STROBING = 0x03, // Strobing effect
30+
MANLI_GPU_MODE_RAINBOW = 0x08, // Rainbow effect (no brightness - HW limitation)
31+
MANLI_GPU_MODE_COLOR_CYCLE = 0x10, // Color Cycle (breathing + flag 0x07)
32+
};
33+
34+
struct ManliGPUConfig
35+
{
36+
int numberOfZones = 0;
37+
bool supportsExternalLEDStrip = false;
38+
};
39+
40+
struct ManliGPUZone
41+
{
42+
int mode = 0;
43+
RGBColor color1 = ToRGBColor(0, 0, 0);
44+
unsigned int speed = 0;
45+
unsigned int brightness = 0;
46+
};
47+
48+
class ManliGPUController
49+
{
50+
public:
51+
ManliGPUController(i2c_smbus_interface* bus, u8 dev, std::string dev_name);
52+
~ManliGPUController();
53+
54+
std::string GetDeviceLocation();
55+
std::string GetName();
56+
std::string GetVersion();
57+
58+
bool TurnOnOff(bool on);
59+
bool SetMode(ManliGPUZone zoneConfig);
60+
61+
private:
62+
i2c_smbus_interface* bus;
63+
u8 dev;
64+
std::string name;
65+
std::string version;
66+
67+
bool ReadVersion();
68+
bool SendCommand(bool on, ManliGPUZone zoneConfig);
69+
};
70+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*---------------------------------------------------------*\
2+
| ManliGPUControllerDetect.cpp |
3+
| |
4+
| Detector for Manli GPU |
5+
| |
6+
| Based on ZotacV2GPUControllerDetect |
7+
| Adapted for Manli RTX 4090 Gallardo |
8+
| |
9+
| This file is part of the OpenRGB project |
10+
| SPDX-License-Identifier: GPL-2.0-or-later |
11+
\*---------------------------------------------------------*/
12+
13+
#include "Detector.h"
14+
#include "ManliGPUController.h"
15+
#include "RGBController_ManliGPU.h"
16+
#include "i2c_smbus.h"
17+
#include "pci_ids.h"
18+
#include "LogManager.h"
19+
20+
/******************************************************************************************\
21+
* *
22+
* DetectManliGPUControllers *
23+
* *
24+
* Detect Manli GPU RGB controllers on the enumerated I2C busses *
25+
* at address 0x49. *
26+
* *
27+
* bus - pointer to i2c_smbus_interface where RGB device is connected *
28+
* dev - I2C address of RGB device *
29+
* *
30+
\******************************************************************************************/
31+
32+
void DetectManliGPUControllers(i2c_smbus_interface* bus, u8 i2c_addr, const std::string& name)
33+
{
34+
u8 data_pkt[] = { MANLI_GPU_REG_RGB, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
35+
if(bus->i2c_write_block(i2c_addr, sizeof(data_pkt), data_pkt) < 0)
36+
{
37+
return;
38+
}
39+
40+
u8 rdata_pkt[I2C_SMBUS_BLOCK_MAX] = { 0x00 };
41+
int rdata_len = sizeof(rdata_pkt);
42+
43+
if(bus->i2c_read_block(i2c_addr, &rdata_len, rdata_pkt) >= 0)
44+
{
45+
ManliGPUController* controller = new ManliGPUController(bus, i2c_addr, name);
46+
RGBController_ManliGPU* rgb_controller = new RGBController_ManliGPU(controller);
47+
48+
if(rgb_controller->config.numberOfZones > 0)
49+
{
50+
ResourceManager::get()->RegisterRGBController(rgb_controller);
51+
}
52+
else
53+
{
54+
LOG_ERROR("[%s] RGB controller not registered - invalid zone count: %d", name.c_str(), rgb_controller->config.numberOfZones);
55+
delete rgb_controller;
56+
}
57+
}
58+
}
59+
60+
REGISTER_I2C_PCI_DETECTOR("MANLI GeForce RTX 4090 Gallardo", DetectManliGPUControllers, NVIDIA_VEN, NVIDIA_RTX4090_DEV, NVIDIA_SUB_VEN, MANLI_RTX4090_GALLARDO_SUB_DEV, 0x49);
61+

0 commit comments

Comments
 (0)