Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,90 @@
/*---------------------------------------------------------*\
| PatriotViperSteelController.cpp |
| |
| Driver for Patriot Viper Steel RAM |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "PatriotViperSteelController.h"
PatriotViperSteelController::PatriotViperSteelController(i2c_smbus_interface *bus, viper_dev_id dev)
{
this->bus = bus;
this->dev = dev;
strcpy(device_name, "Patriot Viper Steel RGB");
led_count = 5;
}
PatriotViperSteelController::~PatriotViperSteelController()
{
}
std::string PatriotViperSteelController::GetDeviceName()
{
return(device_name);
}
std::string PatriotViperSteelController::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);
}
unsigned int PatriotViperSteelController::GetLEDCount()
{
return(led_count);
}
unsigned int PatriotViperSteelController::GetSlotCount()
{
unsigned int slot_count = 0;
for(int slot = 0; slot < 4; slot++)
{
if((slots_valid & (1 << slot)) != 0)
{
slot_count++;
}
}
return(slot_count);
}
unsigned int PatriotViperSteelController::GetMode()
{
return(mode);
}
void PatriotViperSteelController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_STEEL_REG_LED0_DIRECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_STEEL_REG_LED1_DIRECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_STEEL_REG_LED2_DIRECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_STEEL_REG_LED3_DIRECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_STEEL_REG_LED4_DIRECT_COLOR, red, blue, green);
}
void PatriotViperSteelController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_STEEL_REG_LED0_DIRECT_COLOR + led, red, blue, green);
}
void PatriotViperSteelController::SetLEDColor(unsigned int /*slot*/, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_STEEL_REG_LED0_DIRECT_COLOR + led, red, blue, green);
}
void PatriotViperSteelController::ViperRegisterWrite(viper_register reg, unsigned char val0, unsigned char val1, unsigned char val2)
{
bus->i2c_smbus_write_byte_data(dev, reg, val0);
bus->i2c_smbus_write_byte_data(dev, val2, val1);
}
@@ -0,0 +1,53 @@
/*---------------------------------------------------------*\
| PatriotViperSteelController.h |
| |
| Driver for Patriot Viper Steel RAM |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include "i2c_smbus.h"
typedef unsigned char viper_dev_id;
typedef unsigned char viper_register;
enum
{
VIPER_STEEL_REG_LED0_DIRECT_COLOR = 0x17, /* LED 0 Color (R, B, G) */
VIPER_STEEL_REG_LED1_DIRECT_COLOR = 0x18, /* LED 1 Color (R, B, G) */
VIPER_STEEL_REG_LED2_DIRECT_COLOR = 0x19, /* LED 2 Color (R, B, G) */
VIPER_STEEL_REG_LED3_DIRECT_COLOR = 0x1a, /* LED 3 Color (R, B, G) */
VIPER_STEEL_REG_LED4_DIRECT_COLOR = 0x1b, /* LED 4 Color (R, B, G) */
};
class PatriotViperSteelController
{
public:
PatriotViperSteelController(i2c_smbus_interface *bus, viper_dev_id dev);
~PatriotViperSteelController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned int GetSlotCount();
unsigned int GetMode();
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void ViperRegisterWrite(viper_register reg, unsigned char val0, unsigned char val1, unsigned char val2);
bool direct;
private:
char device_name[32];
unsigned int led_count;
unsigned char slots_valid;
i2c_smbus_interface *bus;
viper_dev_id dev;
unsigned char mode;
};
@@ -0,0 +1,94 @@
/*---------------------------------------------------------*\
| PatriotViperSteelControllerDetect.cpp |
| |
| Detector for Patriot Viper Steel RAM |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <vector>
#include "Detector.h"
#include "PatriotViperSteelController.h"
#include "LogManager.h"
#include "RGBController_PatriotViperSteel.h"
#include "i2c_smbus.h"
#include "pci_ids.h"
using namespace std::chrono_literals;
#define PATRIOT_CONTROLLER_NAME "Patriot Viper Steel"
/******************************************************************************************\
* *
* TestForPatriotViperSteelController *
* *
* Tests the given address to see if a Patriot Viper Steel controller exists there. *
* *
\******************************************************************************************/
bool TestForPatriotViperSteelController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
LOG_DEBUG("[%s] Writing at address %02X, res=%02X", PATRIOT_CONTROLLER_NAME, address, res);
if (res >= 0)
{
pass = true;
}
return(pass);
} /* TestForPatriotViperSteelController() */
/******************************************************************************************\
* *
* DetectPatriotViperSteelControllers *
* *
* Detect Patriot Viper Steel RGB controllers on the enumerated I2C busses. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectPatriotViperSteelControllers(i2c_smbus_interface* bus, std::vector<SPDWrapper*> &slots, const std::string &/*name*/)
{
unsigned char slots_valid = 0x00;
// Check for Patriot Viper controller at 0x77
LOG_DEBUG("[%s] Testing bus %d at address 0x77", PATRIOT_CONTROLLER_NAME, bus->port_id);
if(TestForPatriotViperSteelController(bus, 0x77))
{
for(SPDWrapper *slot : slots)
{
if((slot->manufacturer_data(0x00) == 0x50)
&&(slot->manufacturer_data(0x01) == 0x44)
&&(slot->manufacturer_data(0x02) == 0x41)
&&(slot->manufacturer_data(0x03) == 0x31)
&&(slot->manufacturer_data(0x04) == 0x00)
&&(slot->manufacturer_data(0x05) == 0x00)
&&(slot->manufacturer_data(0x06) == 0x00)
&&(slot->manufacturer_data(0x07) == 0x00))
{
LOG_DEBUG("[%s] The RAM module detected in slot %d", PATRIOT_CONTROLLER_NAME, slot->index());
slots_valid |= (1 << (slot->index()));
}
}
if(slots_valid != 0)
{
PatriotViperSteelController* controller = new PatriotViperSteelController(bus, 0x77);
RGBController_PatriotViperSteel* rgb_controller = new RGBController_PatriotViperSteel(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
} /* DetectPatriotViperSteelControllers() */
REGISTER_I2C_DIMM_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperSteelControllers, 0xFF7E, SPD_DDR4_SDRAM);
@@ -0,0 +1,117 @@
/*---------------------------------------------------------*\
| RGBController_PatriotViperSteel.cpp |
| |
| RGBController for Patriot Viper Steel RAM |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_PatriotViperSteel.h"
/**------------------------------------------------------------------*\
@name Patriot Viper Steel
@category RAM
@type I2C
@save :x:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectPatriotViperSteelControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_PatriotViperSteel::RGBController_PatriotViperSteel(PatriotViperSteelController *viper_ptr)
{
controller = viper_ptr;
name = controller->GetDeviceName();
vendor = "Patriot";
type = DEVICE_TYPE_DRAM;
description = "Patriot Viper Steel Device";
location = controller->GetDeviceLocation();
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.speed_min = 0;
Direct.speed_max = 0;
Direct.color_mode = MODE_COLORS_PER_LED;
Direct.speed = 0;
modes.push_back(Direct);
SetupZones();
}
RGBController_PatriotViperSteel::~RGBController_PatriotViperSteel()
{
delete controller;
}
void RGBController_PatriotViperSteel::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
zone *new_zone = new zone;
new_zone->name = "Patriot Viper Steel RGB";
new_zone->type = ZONE_TYPE_LINEAR;
new_zone->leds_min = 5;
new_zone->leds_max = 5;
new_zone->leds_count = 5;
new_zone->matrix_map = NULL;
zones.push_back(*new_zone);
/*---------------------------------------------------------*\
| Set up LEDs |
\*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{
led *new_led = new led();
new_led->name = "Patriot Viper RGB LED ";
new_led->name.append(std::to_string(led_idx + 1));
leds.push_back(*new_led);
}
SetupColors();
}
void RGBController_PatriotViperSteel::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_PatriotViperSteel::DeviceUpdateLEDs()
{
for(int led = 0; led < 5; led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
controller->SetLEDColor(led, red, grn, blu);
}
}
void RGBController_PatriotViperSteel::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_PatriotViperSteel::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
controller->SetLEDColor(led, red, grn, blu);
}
void RGBController_PatriotViperSteel::DeviceUpdateMode()
{
}
@@ -0,0 +1,32 @@
/*---------------------------------------------------------*\
| RGBController_PatriotViperSteel.h |
| |
| RGBController for Patriot Viper Steel RAM |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "PatriotViperSteelController.h"
class RGBController_PatriotViperSteel : public RGBController
{
public:
RGBController_PatriotViperSteel(PatriotViperSteelController *controller_ptr);
~RGBController_PatriotViperSteel();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
PatriotViperSteelController *controller;
};