Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions Controllers/ManliGPUController/ManliGPUController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*---------------------------------------------------------*\
| ManliGPUController.cpp |
| |
| Driver for Manli GPU RGB controllers |
| |
| Based on ZotacV2GPUController |
| Adapted for Manli RTX 4090 Gallardo |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/

#include "ManliGPUController.h"

ManliGPUController::ManliGPUController(i2c_smbus_interface* bus, u8 dev, std::string dev_name)
{
this->bus = bus;
this->dev = dev;
this->name = dev_name;

if(dev)
{
ReadVersion();
}
}

ManliGPUController::~ManliGPUController()
{
}

std::string ManliGPUController::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);
}

std::string ManliGPUController::GetName()
{
return(name);
}

std::string ManliGPUController::GetVersion()
{
return(version);
}

bool ManliGPUController::ReadVersion()
{
u8 data_pkt[] = { MANLI_GPU_REG_RGB, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
if(bus->i2c_write_block(dev, sizeof(data_pkt), data_pkt) < 0)
{
return false;
}

u8 rdata_pkt[I2C_SMBUS_BLOCK_MAX] = { 0x00 };
int rdata_len = sizeof(rdata_pkt);
if(bus->i2c_read_block(dev, &rdata_len, rdata_pkt) < 0)
{
return false;
}

version = std::string((char*)rdata_pkt);
return true;
}

bool ManliGPUController::TurnOnOff(bool on)
{
ManliGPUZone zoneConfig;
return SendCommand(on, zoneConfig);
}

bool ManliGPUController::SetMode(ManliGPUZone zoneConfig)
{
return SendCommand(true, zoneConfig);
}

bool ManliGPUController::SendCommand(bool on, ManliGPUZone zoneConfig)
{
/*---------------------------------------------------------*\
| Color Cycle: Uses breathing mode (0x01) with flag 0x07 |
| This cycles through colors with brightness and speed |
\*---------------------------------------------------------*/
if(zoneConfig.mode == MANLI_GPU_MODE_COLOR_CYCLE)
{
u8 data_pkt[30] = { 0x00 };
data_pkt[0] = on ? (u8)0x01 : (u8)0x00;
data_pkt[6] = 0x01; // mode = breathing
data_pkt[7] = 0x00; // R
data_pkt[8] = 0x00; // G
data_pkt[9] = 0x00; // B
data_pkt[10] = (u8)zoneConfig.speed;
data_pkt[11] = (u8)zoneConfig.brightness;
data_pkt[13] = 0x07; // color cycle flag

if(bus->i2c_smbus_write_i2c_block_data(dev, MANLI_GPU_REG_RGB, sizeof(data_pkt), data_pkt) < 0)
{
return false;
}
return true;
}
/*---------------------------------------------------------*\
| Standard modes (Static, Breathing, Wave, Strobing, Rainbow)|
\*---------------------------------------------------------*/
else
{
u8 data_pkt[30] = { 0x00 };
data_pkt[0] = on ? (u8)0x01 : (u8)0x00;
data_pkt[6] = (u8)zoneConfig.mode;
data_pkt[7] = (u8)RGBGetRValue(zoneConfig.color1);
data_pkt[8] = (u8)RGBGetGValue(zoneConfig.color1);
data_pkt[9] = (u8)RGBGetBValue(zoneConfig.color1);
data_pkt[10] = (u8)zoneConfig.speed;
data_pkt[11] = (u8)zoneConfig.brightness;

if(bus->i2c_smbus_write_i2c_block_data(dev, MANLI_GPU_REG_RGB, sizeof(data_pkt), data_pkt) < 0)
{
return false;
}
return true;
}
}
70 changes: 70 additions & 0 deletions Controllers/ManliGPUController/ManliGPUController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*---------------------------------------------------------*\
| ManliGPUController.h |
| |
| Driver for Manli GPU RGB controllers |
| |
| Based on ZotacV2GPUController |
| Adapted for Manli RTX 4090 Gallardo |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/

#pragma once

#include <string>
#include "i2c_smbus.h"
#include "RGBController.h"

enum
{
MANLI_GPU_REG_RGB = 0xA0,
};

enum
{
MANLI_GPU_MODE_STATIC = 0x00, // Static color
MANLI_GPU_MODE_BREATHING = 0x01, // Breathing effect
MANLI_GPU_MODE_WAVE = 0x02, // Wave effect (no brightness - HW limitation)
MANLI_GPU_MODE_STROBING = 0x03, // Strobing effect
MANLI_GPU_MODE_RAINBOW = 0x08, // Rainbow effect (no brightness - HW limitation)
MANLI_GPU_MODE_COLOR_CYCLE = 0x10, // Color Cycle (breathing + flag 0x07)
};

struct ManliGPUConfig
{
int numberOfZones = 0;
bool supportsExternalLEDStrip = false;
};

struct ManliGPUZone
{
int mode = 0;
RGBColor color1 = ToRGBColor(0, 0, 0);
unsigned int speed = 0;
unsigned int brightness = 0;
};

class ManliGPUController
{
public:
ManliGPUController(i2c_smbus_interface* bus, u8 dev, std::string dev_name);
~ManliGPUController();

std::string GetDeviceLocation();
std::string GetName();
std::string GetVersion();

bool TurnOnOff(bool on);
bool SetMode(ManliGPUZone zoneConfig);

private:
i2c_smbus_interface* bus;
u8 dev;
std::string name;
std::string version;

bool ReadVersion();
bool SendCommand(bool on, ManliGPUZone zoneConfig);
};

61 changes: 61 additions & 0 deletions Controllers/ManliGPUController/ManliGPUControllerDetect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*---------------------------------------------------------*\
| ManliGPUControllerDetect.cpp |
| |
| Detector for Manli GPU |
| |
| Based on ZotacV2GPUControllerDetect |
| Adapted for Manli RTX 4090 Gallardo |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/

#include "Detector.h"
#include "ManliGPUController.h"
#include "RGBController_ManliGPU.h"
#include "i2c_smbus.h"
#include "pci_ids.h"
#include "LogManager.h"

/******************************************************************************************\
* *
* DetectManliGPUControllers *
* *
* Detect Manli GPU RGB controllers on the enumerated I2C busses *
* at address 0x49. *
* *
* bus - pointer to i2c_smbus_interface where RGB device is connected *
* dev - I2C address of RGB device *
* *
\******************************************************************************************/

void DetectManliGPUControllers(i2c_smbus_interface* bus, u8 i2c_addr, const std::string& name)
{
u8 data_pkt[] = { MANLI_GPU_REG_RGB, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
if(bus->i2c_write_block(i2c_addr, sizeof(data_pkt), data_pkt) < 0)
{
return;
}

u8 rdata_pkt[I2C_SMBUS_BLOCK_MAX] = { 0x00 };
int rdata_len = sizeof(rdata_pkt);

if(bus->i2c_read_block(i2c_addr, &rdata_len, rdata_pkt) >= 0)
{
ManliGPUController* controller = new ManliGPUController(bus, i2c_addr, name);
RGBController_ManliGPU* rgb_controller = new RGBController_ManliGPU(controller);

if(rgb_controller->config.numberOfZones > 0)
{
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
else
{
LOG_ERROR("[%s] RGB controller not registered - invalid zone count: %d", name.c_str(), rgb_controller->config.numberOfZones);
delete rgb_controller;
}
}
}

REGISTER_I2C_PCI_DETECTOR("MANLI GeForce RTX 4090 Gallardo", DetectManliGPUControllers, NVIDIA_VEN, NVIDIA_RTX4090_DEV, NVIDIA_SUB_VEN, MANLI_RTX4090_GALLARDO_SUB_DEV, 0x49);

Loading