Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| MSIRGBController.cpp |
|
||||
| |
|
||||
| Driver for MSI-RGB motherboard |
|
||||
| |
|
||||
| Logic adapted from https://github.com/nagisa/msi-rgb |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 11 Feb 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "MSIRGBController.h"
|
||||
#include "dmiinfo.h"
|
||||
#include "super_io.h"
|
||||
|
||||
MSIRGBController::MSIRGBController(int sioaddr, bool invert, std::string dev_name)
|
||||
{
|
||||
msi_sioaddr = sioaddr;
|
||||
name = dev_name;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| This setup step isn't well documented |
|
||||
| Without this, pulsing does not work |
|
||||
\*-----------------------------------------------------*/
|
||||
superio_outb(msi_sioaddr, SIO_REG_LOGDEV, 0x09);
|
||||
|
||||
int val_at_2c = superio_inb(msi_sioaddr, 0x2C);
|
||||
|
||||
val_at_2c &= 0b11110111;
|
||||
val_at_2c |= 0b00010000;
|
||||
|
||||
superio_outb(msi_sioaddr, 0x2C, val_at_2c);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set logical device register to RGB controller |
|
||||
\*-----------------------------------------------------*/
|
||||
superio_outb(msi_sioaddr, SIO_REG_LOGDEV, MSI_SIO_LOGDEV_RGB);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Test if RGB is enabled. If it is not, enable it. |
|
||||
\*-----------------------------------------------------*/
|
||||
int enable = superio_inb(msi_sioaddr, MSI_SIO_RGB_REG_ENABLE);
|
||||
|
||||
if((enable & MSI_SIO_RGB_ENABLE_MASK) != MSI_SIO_RGB_ENABLE_MASK)
|
||||
{
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_ENABLE, 0xE0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Lighting enabled, no pulsing or blinking |
|
||||
\*-----------------------------------------------------*/
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_CFG_1, 0x00);
|
||||
|
||||
/*--------------------------------------------------------------*\
|
||||
| Header on, pulse deactivated, colors inverted depending on DMI |
|
||||
\*--------------------------------------------------------------*/
|
||||
unsigned char ff_val = 0b11100010;
|
||||
|
||||
if (invert)
|
||||
{
|
||||
ff_val |= 0b00011100;
|
||||
}
|
||||
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_CFG_3, ff_val);
|
||||
/*-----------------------------------------------------------*\
|
||||
| This seems to be related to some rainbow mode. Deactivated |
|
||||
\*-----------------------------------------------------------*/
|
||||
superio_outb(msi_sioaddr, 0xFD, 0x00);
|
||||
}
|
||||
|
||||
MSIRGBController::~MSIRGBController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string MSIRGBController::GetDeviceLocation()
|
||||
{
|
||||
char hex[12];
|
||||
snprintf(hex, sizeof(hex), "0x%X", msi_sioaddr);
|
||||
return("SIO: " + std::string(hex));
|
||||
}
|
||||
|
||||
std::string MSIRGBController::GetDeviceName()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
void MSIRGBController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| The MSI RGB controller uses 4 bits per color rather |
|
||||
| than 8. Shift the values by 4 so that the 4 most |
|
||||
| significant bits of each color are the new color value|
|
||||
\*-----------------------------------------------------*/
|
||||
red = red >> 4;
|
||||
green = green >> 4;
|
||||
blue = blue >> 4;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set logical device register to RGB controller |
|
||||
\*-----------------------------------------------------*/
|
||||
superio_outb(msi_sioaddr, SIO_REG_LOGDEV, MSI_SIO_LOGDEV_RGB);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Write the colors to the color sequence registers |
|
||||
| Only static mode is supported right now - all colors |
|
||||
| are the same. |
|
||||
\*-----------------------------------------------------*/
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_1_0, (red | (red << 4)));
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_3_2, (red | (red << 4)));
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_5_4, (red | (red << 4)));
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_7_6, (red | (red << 4)));
|
||||
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_1_0, (green | (green << 4)));
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_3_2, (green | (green << 4)));
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_5_4, (green | (green << 4)));
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_7_6, (green | (green << 4)));
|
||||
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_1_0, (blue | (blue << 4)));
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_3_2, (blue | (blue << 4)));
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_5_4, (blue | (blue << 4)));
|
||||
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_7_6, (blue | (blue << 4)));
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| MSIRGBController.h |
|
||||
| |
|
||||
| Driver for MSI-RGB motherboard |
|
||||
| |
|
||||
| Logic adapted from https://github.com/nagisa/msi-rgb |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 11 Feb 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#define MSI_SIO_LOGDEV_RGB 0x12
|
||||
|
||||
enum
|
||||
{
|
||||
MSI_SIO_RGB_REG_ENABLE = 0xE0,
|
||||
MSI_SIO_RGB_REG_CFG_1 = 0xE4,
|
||||
MSI_SIO_RGB_REG_RED_1_0 = 0xF0,
|
||||
MSI_SIO_RGB_REG_RED_3_2 = 0xF1,
|
||||
MSI_SIO_RGB_REG_RED_5_4 = 0xF2,
|
||||
MSI_SIO_RGB_REG_RED_7_6 = 0xF3,
|
||||
MSI_SIO_RGB_REG_GREEN_1_0 = 0xF4,
|
||||
MSI_SIO_RGB_REG_GREEN_3_2 = 0xF5,
|
||||
MSI_SIO_RGB_REG_GREEN_5_4 = 0xF6,
|
||||
MSI_SIO_RGB_REG_GREEN_7_6 = 0xF7,
|
||||
MSI_SIO_RGB_REG_BLUE_1_0 = 0xF8,
|
||||
MSI_SIO_RGB_REG_BLUE_3_2 = 0xF9,
|
||||
MSI_SIO_RGB_REG_BLUE_5_4 = 0xFA,
|
||||
MSI_SIO_RGB_REG_BLUE_7_6 = 0xFB,
|
||||
MSI_SIO_RGB_REG_CFG_2 = 0xFE,
|
||||
MSI_SIO_RGB_REG_CFG_3 = 0xFF,
|
||||
};
|
||||
|
||||
#define MSI_SIO_RGB_ENABLE_MASK 0xE0
|
||||
|
||||
class MSIRGBController
|
||||
{
|
||||
public:
|
||||
MSIRGBController(int sioaddr, bool invert, std::string dev_name);
|
||||
~MSIRGBController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
|
||||
unsigned int GetMode();
|
||||
void SetMode(unsigned char new_mode, unsigned char new_speed);
|
||||
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
private:
|
||||
int msi_sioaddr;
|
||||
std::string name;
|
||||
};
|
||||
@@ -0,0 +1,129 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| MSIRGBControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for MSI-RGB motherboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 11 Feb 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "MSIRGBController.h"
|
||||
#include "RGBController_MSIRGB.h"
|
||||
#include "super_io.h"
|
||||
#include "dmiinfo.h"
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectMSIRGBControllers *
|
||||
* *
|
||||
* Detect MSI-RGB compatible Super-IO chips. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#define NUM_COMPATIBLE_DEVICES (sizeof(compatible_devices) / sizeof(compatible_devices[0]))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
bool invert;
|
||||
} msi_device;
|
||||
|
||||
static msi_device compatible_devices[] =
|
||||
{
|
||||
{"7A40", false},
|
||||
{"7A34", false},
|
||||
{"7A39", false},
|
||||
{"7A38", false},
|
||||
{"7B79", false},
|
||||
{"7B73", false},
|
||||
{"7B61", false},
|
||||
{"7B54", false},
|
||||
{"7B49", false},
|
||||
{"7B48", false},
|
||||
{"7B45", false},
|
||||
{"7B44", false},
|
||||
{"7A59", false},
|
||||
{"7A57", false},
|
||||
{"7A68", false},
|
||||
{"7B40", false},
|
||||
{"7A94", false},
|
||||
{"7B06", false},
|
||||
{"7B08", false}, // B350 KRAIT GAMING (MS-7B08)
|
||||
{"7B09", false},
|
||||
{"7A58", false},
|
||||
{"7A62", false},
|
||||
{"7A69", false},
|
||||
{"7A70", false},
|
||||
{"7A72", false},
|
||||
{"7A78", false},
|
||||
{"7A79", false},
|
||||
{"7A37", false},
|
||||
{"7B89", true },
|
||||
{"7B90", true },
|
||||
{"7B19", true },
|
||||
{"7C02", true },
|
||||
{"7B75", true },
|
||||
{"7B22", true },
|
||||
{"7B23", true },
|
||||
{"7B24", true },
|
||||
{"7B27", true },
|
||||
{"7B30", true },
|
||||
{"7B31", true },
|
||||
{"7B51", true },
|
||||
{"7C04", true },
|
||||
{"7C00", true },
|
||||
{"7B98", true },
|
||||
{"7C22", true },
|
||||
{"7C24", true },
|
||||
{"7C01", true },
|
||||
{"7C39", true },
|
||||
{"7B86", true },
|
||||
{"7B87", true },
|
||||
{"7D95", false}
|
||||
};
|
||||
|
||||
void DetectMSIRGBControllers()
|
||||
{
|
||||
int sio_addrs[2] = {0x2E, 0x4E};
|
||||
|
||||
DMIInfo board;
|
||||
std::string board_dmi = board.getMainboard();
|
||||
std::string manufacturer = board.getManufacturer();
|
||||
|
||||
if (manufacturer != "Micro-Star International Co., Ltd." && manufacturer != "Micro-Star International Co., Ltd" && manufacturer != "MSI")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int sioaddr_idx = 0; sioaddr_idx < 2; sioaddr_idx++)
|
||||
{
|
||||
int sioaddr = sio_addrs[sioaddr_idx];
|
||||
|
||||
superio_enter(sioaddr);
|
||||
|
||||
int val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) | superio_inb(sioaddr, SIO_REG_DEVID + 1);
|
||||
|
||||
switch (val & SIO_ID_MASK)
|
||||
{
|
||||
case SIO_NCT6795_ID:
|
||||
case SIO_NCT6797_ID:
|
||||
for(unsigned int i = 0; i < NUM_COMPATIBLE_DEVICES; i++)
|
||||
{
|
||||
if (board_dmi.find(std::string(compatible_devices[i].name)) != std::string::npos)
|
||||
{
|
||||
MSIRGBController* controller = new MSIRGBController(sioaddr, compatible_devices[i].invert, "MSI " + board_dmi);
|
||||
RGBController_MSIRGB* rgb_controller = new RGBController_MSIRGB(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* DetectMSIRGBControllers() */
|
||||
|
||||
REGISTER_DETECTOR("MSI-RGB", DetectMSIRGBControllers);
|
||||
@@ -0,0 +1,96 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_MSIRGB.cpp |
|
||||
| |
|
||||
| RGBController for MSI-RGB motherboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 14 Feb 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_MSIRGB.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name MSI RGB
|
||||
@category Motherboard
|
||||
@type SuperIO
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :x:
|
||||
@detectors DetectMSIRGBControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_MSIRGB::RGBController_MSIRGB(MSIRGBController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetDeviceName();
|
||||
vendor = "MSI";
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
description = "MSI-RGB Device";
|
||||
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_MSIRGB::~RGBController_MSIRGB()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_MSIRGB::SetupZones()
|
||||
{
|
||||
zone msi_zone;
|
||||
msi_zone.name = "MSI Zone";
|
||||
msi_zone.type = ZONE_TYPE_SINGLE;
|
||||
msi_zone.leds_min = 1;
|
||||
msi_zone.leds_max = 1;
|
||||
msi_zone.leds_count = 1;
|
||||
msi_zone.matrix_map = NULL;
|
||||
zones.push_back(msi_zone);
|
||||
|
||||
led msi_led;
|
||||
msi_led.name = "MSI LED";
|
||||
leds.push_back(msi_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_MSIRGB::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_MSIRGB::DeviceUpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
controller->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_MSIRGB::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_MSIRGB::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_MSIRGB::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_MSIRGB.h |
|
||||
| |
|
||||
| RGBController for MSI-RGB motherboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 14 Feb 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "MSIRGBController.h"
|
||||
|
||||
class RGBController_MSIRGB : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_MSIRGB(MSIRGBController* controller_ptr);
|
||||
~RGBController_MSIRGB();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
MSIRGBController* controller;
|
||||
};
|
||||
Reference in New Issue
Block a user