Filter msi-rgb by dmi

Commits squashed by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
alpemwarrior 2020-12-08 16:20:40 +01:00 committed by Adam Honse
parent 70028e6d23
commit 03bf187c7b
3 changed files with 83 additions and 45 deletions

View file

@ -13,42 +13,9 @@
#include "dependencies/dmiinfo.h"
#include "super_io.h"
#define NUM_INVERTED_DEVICES (sizeof(inverted_devices) / sizeof(inverted_devices[0]))
/*-------------------------------------------------------------------------*\
| This is a list of DMI info for boards which need the inversion flag set |
\*-------------------------------------------------------------------------*/
static const char * inverted_devices[21] =
{
"7B89",
"7B90",
"7B19",
"7C02",
"7B75",
"7B22",
"7B23",
"7B24",
"7B27",
"7B30",
"7B31",
"7B51",
"7C04",
"7C00",
"7B98",
"7C22",
"7C24",
"7C01",
"7C39",
"7B86",
"7B87"
};
MSIRGBController::MSIRGBController(int sioaddr)
MSIRGBController::MSIRGBController(int sioaddr, bool invert)
{
msi_sioaddr = sioaddr;
DMIInfo board;
std::string board_dmi = board.getMainboard();
/*-----------------------------------------------------*\
| This setup step isn't well documented |
@ -89,16 +56,12 @@ MSIRGBController::MSIRGBController(int sioaddr)
\*--------------------------------------------------------------*/
unsigned char ff_val = 0b11100010;
for(unsigned int i = 0; i < NUM_INVERTED_DEVICES; i++)
if (invert)
{
if (board_dmi.find(std::string(inverted_devices[i])) != std::string::npos)
{
ff_val |= 0b00011100;
break;
}
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 |
\*-----------------------------------------------------------*/

View file

@ -40,7 +40,7 @@ enum
class MSIRGBController
{
public:
MSIRGBController(int sioaddr);
MSIRGBController(int sioaddr, bool invert);
~MSIRGBController();
std::string GetDeviceName();

View file

@ -3,6 +3,7 @@
#include "RGBController.h"
#include "RGBController_MSIRGB.h"
#include "super_io.h"
#include "dependencies/dmiinfo.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
@ -15,9 +16,76 @@
* *
\******************************************************************************************/
#define NUM_COMPATIBLE_DEVICES (sizeof(compatible_devices) / sizeof(compatible_devices[0]))
typedef struct
{
const char* name;
bool invert;
} msi_device;
msi_device compatible_devices[] =
{
{"7A40", 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},
{"7B09", false},
{"7B06", false},
{"7A58", false},
{"7A62", false},
{"7A69", false},
{"7A70", false},
{"7A72", false},
{"7A78", false},
{"7A79", 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 },
};
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers)
{
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.")
{
return;
}
for(int sioaddr_idx = 0; sioaddr_idx < 2; sioaddr_idx++)
{
@ -31,10 +99,17 @@ void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers)
{
case SIO_NCT6795_ID:
case SIO_NCT6797_ID:
MSIRGBController* new_msi = new MSIRGBController(sioaddr);
RGBController_MSIRGB* new_rgb = new RGBController_MSIRGB(new_msi);
for(unsigned int i = 0; i < NUM_COMPATIBLE_DEVICES; i++)
{
if (board_dmi.find(std::string(compatible_devices[i].name)) != std::string::npos)
{
MSIRGBController* new_msi = new MSIRGBController(sioaddr, compatible_devices[i].invert);
RGBController_MSIRGB* new_rgb = new RGBController_MSIRGB(new_msi);
rgb_controllers.push_back(new_rgb);
rgb_controllers.push_back(new_rgb);
break;
}
}
break;
}
}