Add values to UI

This commit is contained in:
jussi
2019-02-15 00:55:07 +02:00
parent 3bc366a7da
commit 7828180592
3 changed files with 82 additions and 1 deletions

54
amd.cpp
View File

@@ -92,6 +92,7 @@ void amd::queryGPUFeatures()
// Read the pp_od_clk_voltage file and parse output
QRegularExpression numexp("\\d+\\d");
int type = 0;
int column = 0;
int breakcount = 0;
for (int i=0; i<gpuCount; i++) {
QString path;
@@ -103,6 +104,59 @@ void amd::queryGPUFeatures()
if (ret) {
QTextStream str(&tablefile);
while (!str.atEnd() && breakcount < 30) {
line = str.readLine();
if (line.contains("OD_SCLK")) type = 1;
if (line.contains("OD_MCLK")) type = 2;
if (line.contains("OD_RANGE")) type = 3;
QRegularExpressionMatchIterator iter = numexp.globalMatch(line);
// Read all matches for the line
while (iter.hasNext()) {
QRegularExpressionMatch nummatch = iter.next();
QString capline = nummatch.captured();
int num = capline.toInt();
if (type == 1) {
if (column == 0) {
GPUList[i].corecloks.append(num);
} else {
GPUList[i].corevolts.append(num);
}
}
if (type == 2) {
if (column == 0) {
GPUList[i].memclocks.append(num);
} else {
GPUList[i].memvolts.append(num);
}
}
if (type == 3) {
if (line.contains("sclk", Qt::CaseInsensitive)) {
if (column == 0) {
GPUList[i].minCoreClkLimit = num;
} else {
GPUList[i].maxCoreClkLimit = num;
}
}
if (line.contains("mclk", Qt::CaseInsensitive)) {
if (column == 0) {
GPUList[i].minMemClkLimit = num;
} else {
GPUList[i].maxMemClkLimit = num;
}
}
if (line.contains("vdd", Qt::CaseInsensitive)) {
if (column == 0) {
GPUList[i].minVoltageLimit = num;
} else {
GPUList[i].maxVoltageLimit = num;
}
}
}
column++;
}
column = 0;
breakcount++;
}
tablefile.close();

View File

@@ -75,6 +75,14 @@ public:
// name of the folder in /sys/class/drm/card(n)/device/hwmon
QString hwmonpath;
amdgpu_device_handle *dev;
// Pstate vectors
QVector <int> memvolts, corevolts, memclocks, corecloks;
int maxVoltageLimit;
int minVoltageLimit;
int maxCoreClkLimit;
int minCoreClkLimit;
int maxMemClkLimit;
int minMemClkLimit;
#endif
};
QVector <GPU> GPUList;

View File

@@ -50,6 +50,7 @@ MainWindow::MainWindow(QWidget *parent) :
*/
// Enable sliders according to GPU properties
/*
if (types->GPUList[currentGPUIndex].overClockAvailable) {
ui->frequencySlider->setRange(types->GPUList[currentGPUIndex].minCoreClkOffset, types->GPUList[currentGPUIndex].maxCoreClkOffset);
ui->frequencySpinBox->setRange(types->GPUList[currentGPUIndex].minCoreClkOffset, types->GPUList[currentGPUIndex].maxCoreClkOffset);
@@ -99,7 +100,25 @@ MainWindow::MainWindow(QWidget *parent) :
if (types->GPUList[currentGPUIndex].fanControlMode !=1) {
ui->fanSlider->setDisabled(true);
ui->fanSpinBox->setDisabled(true);
}
}*/
// Testing code
ui->voltageSlider->setRange(types->GPUList[currentGPUIndex].minVoltageLimit, types->GPUList[currentGPUIndex].maxVoltageOffset);
ui->voltageSpinBox->setRange(types->GPUList[currentGPUIndex].minVoltageLimit, types->GPUList[currentGPUIndex].maxVoltageOffset);
ui->powerLimSlider->setRange(types->GPUList[currentGPUIndex].minPowerLim, types->GPUList[currentGPUIndex].maxPowerLim);
ui->powerLimSpinBox->setRange(types->GPUList[currentGPUIndex].minPowerLim, types->GPUList[currentGPUIndex].maxPowerLim);
ui->frequencySpinBox->setRange(types->GPUList[currentGPUIndex].minCoreClkLimit, types->GPUList[currentGPUIndex].maxCoreClkLimit);
ui->frequencySlider->setRange(types->GPUList[currentGPUIndex].minCoreClkLimit, types->GPUList[currentGPUIndex].maxCoreClkLimit);
ui->memClkSlider->setRange(types->GPUList[currentGPUIndex].minMemClkLimit, types->GPUList[currentGPUIndex].maxMemClkLimit);
ui->memClkSpinBox->setRange(types->GPUList[currentGPUIndex].minMemClkLimit, types->GPUList[currentGPUIndex].maxMemClkLimit);
ui->memClkSlider->setValue(types->GPUList[currentGPUIndex].memclocks[types->GPUList[currentGPUIndex].memclocks.size()]);
ui->frequencySlider->setValue(types->GPUList[currentGPUIndex].corecloks[types->GPUList[currentGPUIndex].corecloks.size()]);
ui->powerLimSlider->setValue(types->GPUList[currentGPUIndex].powerLim);
ui->voltageSlider->setValue(types->GPUList[currentGPUIndex].corevolts[types->GPUList[currentGPUIndex].corevolts.size()]);
if (!types->GPUList[currentGPUIndex].manualFanCtrlAvailable) {
// If manual fan control is not available for the GPU, disable the option