mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
add more amd functionality
This commit is contained in:
parent
882a37dff2
commit
41438d23b4
122
amd.cpp
122
amd.cpp
@ -4,27 +4,133 @@
|
|||||||
amd::amd() {}
|
amd::amd() {}
|
||||||
bool amd::setupGPU()
|
bool amd::setupGPU()
|
||||||
{
|
{
|
||||||
return true;
|
bool retb = false;
|
||||||
|
qDebug("setting up amd gpu");
|
||||||
|
// Check if the amdgpu driver is present on any of the cards in /dev/dri
|
||||||
|
QDir devdir("/dev/dri");
|
||||||
|
QStringList filelist = devdir.entryList();
|
||||||
|
// First check for /dev/dri/renderD(128 + n)
|
||||||
|
int fd = 0;
|
||||||
|
for (int i=0; i<filelist.size(); i++) {
|
||||||
|
QFileInfo info(devdir, "renderD"+QString::number(128+i));
|
||||||
|
//qDebug() << info.exists();
|
||||||
|
if (info.exists()) {
|
||||||
|
// Get file descriptor for the device
|
||||||
|
// Convert info.path to char
|
||||||
|
char *path;
|
||||||
|
QString abspath = "/dev/dri/renderD"+QString::number(128 + i);
|
||||||
|
QByteArray arr = abspath.toLocal8Bit();
|
||||||
|
path = arr.data();
|
||||||
|
fd = open(path, O_RDONLY);
|
||||||
|
qDebug() << info.fileName() << fd;
|
||||||
|
|
||||||
|
// Attempt to initialize the GPU
|
||||||
|
uint32_t major = 0;
|
||||||
|
uint32_t minor = 0;
|
||||||
|
amdgpu_device_handle handle;
|
||||||
|
dev = &handle;
|
||||||
|
int ret = amdgpu_device_initialize(fd, &major, &minor, dev);
|
||||||
|
qDebug() << major;
|
||||||
|
if (ret > -1) {
|
||||||
|
// Create a gpu object with the correct paremeters
|
||||||
|
GPU gpu;
|
||||||
|
gpu.fsindex = i;
|
||||||
|
gpu.gputype = Type::AMDGPU;
|
||||||
|
GPUList.append(gpu);
|
||||||
|
|
||||||
|
retb = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!retb) {
|
||||||
|
qDebug("No AMD GPUs using amdgpu found");
|
||||||
|
} else {
|
||||||
|
queryGPUNames();
|
||||||
|
}
|
||||||
|
return retb;
|
||||||
}
|
}
|
||||||
bool amd::setupGPUSecondary(int GPUIndex){return true;}
|
bool amd::setupGPUSecondary(int GPUIndex){return true;}
|
||||||
void amd::queryGPUCount(){}
|
void amd::queryGPUCount(){}
|
||||||
void amd::queryGPUNames(){}
|
void amd::queryGPUNames()
|
||||||
|
{
|
||||||
|
for (int i=0; i<GPUList.size(); i++) {
|
||||||
|
if (GPUList[i].gputype == Type::AMDGPU) {
|
||||||
|
const char *name;
|
||||||
|
name = amdgpu_get_marketing_name(*dev);
|
||||||
|
//strcpy(GPUList[i].name, name);
|
||||||
|
qDebug() << name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void amd::queryGPUUIDs(){}
|
void amd::queryGPUUIDs(){}
|
||||||
void amd::queryGPUFeatures(){}
|
void amd::queryGPUFeatures(){}
|
||||||
void amd::queryGPUVoltage(int GPUIndex){}
|
void amd::queryGPUVoltage(int GPUIndex)
|
||||||
void amd::queryGPUTemp(int GPUIndex){}
|
{
|
||||||
void amd::queryGPUFrequencies(int GPUIndex){}
|
int ret = amdgpu_query_sensor_info(*dev,
|
||||||
|
AMDGPU_INFO_SENSOR_VDDGFX,
|
||||||
|
sizeof (GPUList[GPUIndex].voltage),
|
||||||
|
&GPUList[GPUIndex].voltage);
|
||||||
|
if (ret < 0) qDebug("Failed to query voltage");
|
||||||
|
}
|
||||||
|
void amd::queryGPUTemp(int GPUIndex)
|
||||||
|
{
|
||||||
|
int ret = amdgpu_query_sensor_info(*dev,
|
||||||
|
AMDGPU_INFO_SENSOR_GPU_TEMP,
|
||||||
|
sizeof (GPUList[GPUIndex].temp),
|
||||||
|
&GPUList[GPUIndex].temp);
|
||||||
|
if (ret < 0) qDebug("Failed to query GPU temperature");
|
||||||
|
}
|
||||||
|
void amd::queryGPUFrequencies(int GPUIndex)
|
||||||
|
{
|
||||||
|
int ret = amdgpu_query_sensor_info(*dev,
|
||||||
|
AMDGPU_INFO_SENSOR_GFX_SCLK,
|
||||||
|
sizeof (GPUList[GPUIndex].coreFreq),
|
||||||
|
&GPUList[GPUIndex].coreFreq);
|
||||||
|
if (ret < 0) qDebug("Failed to query GPU core clock");
|
||||||
|
|
||||||
|
ret = amdgpu_query_sensor_info(*dev,
|
||||||
|
AMDGPU_INFO_SENSOR_GFX_MCLK,
|
||||||
|
sizeof (GPUList[GPUIndex].memFreq),
|
||||||
|
&GPUList[GPUIndex].memFreq);
|
||||||
|
if (ret < 0) qDebug("Failed to query GPU memory clock");
|
||||||
|
}
|
||||||
void amd::queryGPUFanSpeed(int GPUIndex){}
|
void amd::queryGPUFanSpeed(int GPUIndex){}
|
||||||
void amd::queryGPUUsedVRAM(int GPUIndex){}
|
void amd::queryGPUUsedVRAM(int GPUIndex){}
|
||||||
void amd::queryGPUFreqOffset(int GPUIndex){}
|
void amd::queryGPUFreqOffset(int GPUIndex){}
|
||||||
void amd::queryGPUMemClkOffset(int GPUIndex){}
|
void amd::queryGPUMemClkOffset(int GPUIndex){}
|
||||||
void amd::queryGPUVoltageOffset(int GPUIndex){}
|
void amd::queryGPUVoltageOffset(int GPUIndex){}
|
||||||
|
|
||||||
void amd::queryGPUUtils(int GPUIndex){}
|
void amd::queryGPUUtils(int GPUIndex)
|
||||||
void amd::queryGPUPowerDraw(int GPUIndex){}
|
{
|
||||||
|
int ret = amdgpu_query_sensor_info(*dev,
|
||||||
|
AMDGPU_INFO_SENSOR_GPU_LOAD,
|
||||||
|
sizeof (GPUList[GPUIndex].coreUtil),
|
||||||
|
&GPUList[GPUIndex].coreUtil);
|
||||||
|
if (ret < 0) qDebug("Failed to query GPU Utilization");
|
||||||
|
}
|
||||||
|
void amd::queryGPUPowerDraw(int GPUIndex)
|
||||||
|
{
|
||||||
|
int ret = amdgpu_query_sensor_info(*dev,
|
||||||
|
AMDGPU_INFO_SENSOR_GPU_AVG_POWER,
|
||||||
|
sizeof (GPUList[GPUIndex].powerDraw),
|
||||||
|
&GPUList[GPUIndex].powerDraw);
|
||||||
|
if (ret < 0) qDebug("failed to query GPU power draw");
|
||||||
|
}
|
||||||
void amd::queryGPUPowerLimit(int GPUIndex){}
|
void amd::queryGPUPowerLimit(int GPUIndex){}
|
||||||
void amd::queryGPUPowerLimitLimits(int GPUIndex){}
|
void amd::queryGPUPowerLimitLimits(int GPUIndex){}
|
||||||
void amd::queryGPUCurrentMaxClocks(int GPUIndex){}
|
void amd::queryGPUCurrentMaxClocks(int GPUIndex)
|
||||||
|
{
|
||||||
|
amdgpu_gpu_info info;
|
||||||
|
int ret = amdgpu_query_gpu_info(*dev, &info);
|
||||||
|
if (ret < 0) qDebug("Failed to query GPU maximum clocks");
|
||||||
|
else {
|
||||||
|
uint clock = static_cast<uint>(info.max_engine_clk);
|
||||||
|
GPUList[GPUIndex].maxCoreClk = clock/1000;
|
||||||
|
|
||||||
|
clock = static_cast<uint>(info.max_memory_clk);
|
||||||
|
GPUList[GPUIndex].maxMemClk = clock/1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
void amd::queryGPUPowerLimitAvailability(int GPUIndex){}
|
void amd::queryGPUPowerLimitAvailability(int GPUIndex){}
|
||||||
|
|
||||||
bool amd::assignGPUFanSpeed(int GPUIndex, int targetValue){}
|
bool amd::assignGPUFanSpeed(int GPUIndex, int targetValue){}
|
||||||
|
20
gputypes.h
20
gputypes.h
@ -4,17 +4,27 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
#include <QtX11Extras/QX11Info>
|
#include <QtX11Extras/QX11Info>
|
||||||
#ifdef NVIDIA
|
#ifdef NVIDIA
|
||||||
#include "nvml.h"
|
#include "nvml.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef AMD
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <libdrm/amdgpu_drm.h>
|
||||||
|
#include <libdrm/amdgpu.h>
|
||||||
|
#include <xf86drm.h>
|
||||||
|
#include <xf86drmMode.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
class gputypes : public QObject
|
class gputypes : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
gputypes();
|
gputypes();
|
||||||
//enum Type{NV, AMD};
|
enum Type{NV, AMDGPU};
|
||||||
struct GPU
|
struct GPU
|
||||||
{
|
{
|
||||||
int gputype;
|
int gputype;
|
||||||
@ -56,6 +66,10 @@ public:
|
|||||||
uint powerLim;
|
uint powerLim;
|
||||||
int totalVRAM;
|
int totalVRAM;
|
||||||
int usedVRAM;
|
int usedVRAM;
|
||||||
|
|
||||||
|
// AMD only:
|
||||||
|
// GPU index in the filesystem eg. card0
|
||||||
|
int fsindex;
|
||||||
};
|
};
|
||||||
QVector <GPU> GPUList;
|
QVector <GPU> GPUList;
|
||||||
|
|
||||||
@ -65,6 +79,10 @@ public:
|
|||||||
nvmlDevice_t *device;
|
nvmlDevice_t *device;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef AMD
|
||||||
|
amdgpu_device_handle *dev;
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual bool setupGPU() = 0;
|
virtual bool setupGPU() = 0;
|
||||||
virtual bool setupGPUSecondary(int GPUIndex) = 0;
|
virtual bool setupGPUSecondary(int GPUIndex) = 0;
|
||||||
virtual void queryGPUCount() = 0;
|
virtual void queryGPUCount() = 0;
|
||||||
|
@ -30,8 +30,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
// This is for libxnvctrl
|
// This is for libxnvctrl
|
||||||
types->setupGPU();
|
types->setupGPU();
|
||||||
// This is for NVML
|
// This is for NVML
|
||||||
types->setupGPUSecondary(currentGPUIndex);
|
/*types->setupGPUSecondary(currentGPUIndex);
|
||||||
/*types->queryGPUFeatures();
|
types->queryGPUFeatures();
|
||||||
types->queryGPUFreqOffset(currentGPUIndex);
|
types->queryGPUFreqOffset(currentGPUIndex);
|
||||||
types->queryGPUMemClkOffset(currentGPUIndex);
|
types->queryGPUMemClkOffset(currentGPUIndex);
|
||||||
types->queryGPUVoltageOffset(currentGPUIndex);
|
types->queryGPUVoltageOffset(currentGPUIndex);
|
||||||
@ -43,11 +43,11 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
for (int i=0; i<types->gpuCount; i++) {
|
for (int i=0; i<types->gpuCount; i++) {
|
||||||
ui->GPUComboBox->addItem("GPU-" + QString::number(i) + ": " + types->GPUList[i].name);
|
ui->GPUComboBox->addItem("GPU-" + QString::number(i) + ": " + types->GPUList[i].name);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
loadProfileSettings();
|
loadProfileSettings();
|
||||||
setupMonitorTab();
|
setupMonitorTab();
|
||||||
setupGraphMonitorTab();
|
setupGraphMonitorTab();
|
||||||
/*
|
|
||||||
// Enable sliders according to GPU properties
|
// Enable sliders according to GPU properties
|
||||||
if (types->GPUList[currentGPUIndex].overClockAvailable) {
|
if (types->GPUList[currentGPUIndex].overClockAvailable) {
|
||||||
ui->frequencySlider->setRange(types->GPUList[currentGPUIndex].minCoreClkOffset, types->GPUList[currentGPUIndex].maxCoreClkOffset);
|
ui->frequencySlider->setRange(types->GPUList[currentGPUIndex].minCoreClkOffset, types->GPUList[currentGPUIndex].maxCoreClkOffset);
|
||||||
@ -108,7 +108,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
manualMode->setEnabled(false);
|
manualMode->setEnabled(false);
|
||||||
manualMode->setToolTip("Manual fan control is not available for current GPU");
|
manualMode->setToolTip("Manual fan control is not available for current GPU");
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
connect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(fanSpeedUpdater()));
|
connect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(fanSpeedUpdater()));
|
||||||
fanUpdateTimer->start(2000);
|
fanUpdateTimer->start(2000);
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(ui->voltageSpinBox, SIGNAL(valueChanged(int)), SLOT(resetTimer()));
|
connect(ui->voltageSpinBox, SIGNAL(valueChanged(int)), SLOT(resetTimer()));
|
||||||
|
|
||||||
connect(ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(tabHandler(int)));
|
connect(ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(tabHandler(int)));
|
||||||
connect(monitorUpdater, SIGNAL(timeout()), SLOT(updateMonitor()));
|
connect(monitorUpdater, SIGNAL(timeout()), SLOT(updateMonitor()));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -59,8 +59,10 @@ FORMS += \
|
|||||||
|
|
||||||
INCLUDEPATH += "/usr/lib"
|
INCLUDEPATH += "/usr/lib"
|
||||||
INCLUDEPATH += $$(INCLUDEPATH)
|
INCLUDEPATH += $$(INCLUDEPATH)
|
||||||
|
INCLUDEPATH += "/usr/include/libdrm"
|
||||||
|
|
||||||
#LIBS += -lXext -lXNVCtrl -lX11 -lnvidia-ml
|
#LIBS += -lXext -lXNVCtrl -lX11 -lnvidia-ml
|
||||||
|
LIBS += -ldrm -ldrm_amdgpu
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
Loading…
Reference in New Issue
Block a user