diff --git a/amd.cpp b/amd.cpp index ac1441c..8995934 100644 --- a/amd.cpp +++ b/amd.cpp @@ -30,7 +30,7 @@ bool amd::setupGPU() amdgpu_device_handle handle; int ret = amdgpu_device_initialize(fd, &major, &minor, &handle); qDebug() << major; - if (ret > -1) { + if (ret == 0) { // Create a gpu object with the correct paremeters GPU gpu; gpu.fsindex = i; @@ -56,8 +56,14 @@ bool amd::setupGPU() gpu.displayName = QString::fromUtf8(name); gpu.dev = &handle; qDebug() << gpu.name; - gpuCount++; + + int reading = 0; + uint size = sizeof (int); + ret = amdgpu_query_sensor_info(handle, AMDGPU_INFO_SENSOR_GFX_SCLK, size, &reading); + qDebug() << "coreclk" << reading << ret; + GPUList.append(gpu); + gpuCount++; retb = true; } @@ -87,6 +93,11 @@ void amd::calculateUIProperties(int GPUIndex) GPUList[GPUIndex].powerLimSliderMax = static_cast(GPUList[GPUIndex].maxPowerLim); GPUList[GPUIndex].powerLimSliderMin = static_cast(GPUList[GPUIndex].minPowerLim); + + /*GPUList[GPUIndex].voltageSliderCur = GPUList[GPUIndex].corevolts[GPUList[GPUIndex].corevolts.size()-1]; + GPUList[GPUIndex].powerLimSliderCur = static_cast(GPUList[GPUIndex].powerLim); + GPUList[GPUIndex].memClkSliderCur = GPUList[GPUIndex].memvolts[GPUList[GPUIndex].memclocks.size()-1]; + GPUList[GPUIndex].coreClkSliderCur = GPUList[GPUIndex].coreclocks[GPUList[GPUIndex].coreclocks.size()-1];*/ } bool amd::setupGPUSecondary(int GPUIndex){return true;} void amd::queryGPUCount(){} @@ -185,29 +196,32 @@ void amd::queryGPUVoltage(int GPUIndex) AMDGPU_INFO_SENSOR_VDDGFX, sizeof (GPUList[GPUIndex].voltage), &GPUList[GPUIndex].voltage); - if (ret < 0) qDebug("Failed to query voltage"); + if (ret != 0) qDebug("Failed to query voltage"); } void amd::queryGPUTemp(int GPUIndex) { + qDebug() << "querying GPU" << GPUIndex << GPUList[GPUIndex].displayName; int ret = amdgpu_query_sensor_info(*GPUList[GPUIndex].dev, AMDGPU_INFO_SENSOR_GPU_TEMP, sizeof (GPUList[GPUIndex].temp), &GPUList[GPUIndex].temp); - if (ret < 0) qDebug("Failed to query GPU temperature"); + if (ret != 0) qDebug("Failed to query GPU temperature"); } void amd::queryGPUFrequencies(int GPUIndex) { + int reading; int ret = amdgpu_query_sensor_info(*GPUList[GPUIndex].dev, AMDGPU_INFO_SENSOR_GFX_SCLK, sizeof (GPUList[GPUIndex].coreFreq), - &GPUList[GPUIndex].coreFreq); - if (ret < 0) qDebug("Failed to query GPU core clock"); + &reading); + qDebug() << reading << ret; + if (ret != 0) qDebug("Failed to query GPU core clock"); ret = amdgpu_query_sensor_info(*GPUList[GPUIndex].dev, AMDGPU_INFO_SENSOR_GFX_MCLK, sizeof (GPUList[GPUIndex].memFreq), &GPUList[GPUIndex].memFreq); - if (ret < 0) qDebug("Failed to query GPU memory clock"); + if (ret != 0) qDebug("Failed to query GPU memory clock"); } void amd::queryGPUFanSpeed(int GPUIndex) { @@ -232,7 +246,7 @@ void amd::queryGPUUtils(int GPUIndex) AMDGPU_INFO_SENSOR_GPU_LOAD, sizeof (GPUList[GPUIndex].coreUtil), &GPUList[GPUIndex].coreUtil); - if (ret < 0) qDebug("Failed to query GPU Utilization"); + if (ret != 0) qDebug("Failed to query GPU Utilization"); } void amd::queryGPUPowerDraw(int GPUIndex) { @@ -240,7 +254,7 @@ void amd::queryGPUPowerDraw(int GPUIndex) AMDGPU_INFO_SENSOR_GPU_AVG_POWER, sizeof (GPUList[GPUIndex].powerDraw), &GPUList[GPUIndex].powerDraw); - if (ret < 0) qDebug("failed to query GPU power draw"); + if (ret != 0) qDebug("failed to query GPU power draw"); } void amd::queryGPUPowerLimit(int GPUIndex) { @@ -273,7 +287,7 @@ void amd::queryGPUPowerLimitLimits(int GPUIndex) } void amd::queryGPUCurrentMaxClocks(int GPUIndex) { - amdgpu_gpu_info info; + /*amdgpu_gpu_info info; int ret = amdgpu_query_gpu_info(*GPUList[GPUIndex].dev, &info); if (ret < 0) qDebug("Failed to query GPU maximum clocks"); else { @@ -282,7 +296,7 @@ void amd::queryGPUCurrentMaxClocks(int GPUIndex) clock = static_cast(info.max_memory_clk); GPUList[GPUIndex].maxMemClk = clock/1000; - } + }*/ } void amd::queryGPUPowerLimitAvailability(int GPUIndex){} diff --git a/gputypes.h b/gputypes.h index 1d776e5..000b176 100644 --- a/gputypes.h +++ b/gputypes.h @@ -37,6 +37,11 @@ public: int coreClkSliderMax; int voltageSliderMax; int voltageSliderMin; + + int voltageSliderCur; + int powerLimSliderCur; + int memClkSliderCur; + int coreClkSliderCur; QString displayName; int gputype; diff --git a/mainwindow.cpp b/mainwindow.cpp index a221ee2..df2ddd4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -33,13 +33,13 @@ MainWindow::MainWindow(QWidget *parent) : // This is for NVML types->setupGPUSecondary(currentGPUIndex); types->queryGPUFeatures(); - types->queryGPUFreqOffset(currentGPUIndex); - types->queryGPUMemClkOffset(currentGPUIndex); - types->queryGPUVoltageOffset(currentGPUIndex); + //types->queryGPUFreqOffset(currentGPUIndex); + //types->queryGPUMemClkOffset(currentGPUIndex); + //types->queryGPUVoltageOffset(currentGPUIndex); //types->queryGPUPowerLimit(currentGPUIndex); //types->queryGPUPowerLimitAvailability(currentGPUIndex); //types->queryGPUPowerLimitLimits(currentGPUIndex); - types->queryGPUCurrentMaxClocks(currentGPUIndex); + //types->queryGPUCurrentMaxClocks(currentGPUIndex); if (types->GPUList[currentGPUIndex].gputype == types->AMDGPU) { types->calculateUIProperties(currentGPUIndex); } @@ -47,11 +47,11 @@ MainWindow::MainWindow(QWidget *parent) : for (int i=0; igpuCount; i++) { ui->GPUComboBox->addItem("GPU-" + QString::number(i) + ": " + types->GPUList[i].displayName); } - /* - loadProfileSettings(); - setupMonitorTab(); + + //loadProfileSettings(); + //setupMonitorTab(); setupGraphMonitorTab(); - */ + // Enable sliders according to GPU properties /* @@ -108,7 +108,7 @@ MainWindow::MainWindow(QWidget *parent) : // Testing code - ui->voltageSlider->setRange(types->GPUList[currentGPUIndex].voltageSliderMin, types->GPUList[currentGPUIndex].voltageSliderMax); + /*ui->voltageSlider->setRange(types->GPUList[currentGPUIndex].voltageSliderMin, types->GPUList[currentGPUIndex].voltageSliderMax); ui->voltageSpinBox->setRange(types->GPUList[currentGPUIndex].voltageSliderMin, types->GPUList[currentGPUIndex].voltageSliderMax); ui->powerLimSlider->setRange(types->GPUList[currentGPUIndex].powerLimSliderMin, types->GPUList[currentGPUIndex].powerLimSliderMax); @@ -118,7 +118,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->frequencySlider->setRange(types->GPUList[currentGPUIndex].coreClkSliderMin, types->GPUList[currentGPUIndex].coreClkSliderMin); ui->memClkSlider->setRange(types->GPUList[currentGPUIndex].memClkSliderMin, types->GPUList[currentGPUIndex].memClkSliderMax); - ui->memClkSpinBox->setRange(types->GPUList[currentGPUIndex].memClkSliderMin, types->GPUList[currentGPUIndex].memClkSliderMax); + ui->memClkSpinBox->setRange(types->GPUList[currentGPUIndex].memClkSliderMin, types->GPUList[currentGPUIndex].memClkSliderMax);*/ /*ui->memClkSlider->setValue(types->GPUList[currentGPUIndex].memclocks[types->GPUList[currentGPUIndex].memclocks.size()-1]); ui->frequencySlider->setValue(types->GPUList[currentGPUIndex].corecloks[types->GPUList[currentGPUIndex].corecloks.size()-1]); @@ -143,7 +143,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->voltageSpinBox, SIGNAL(valueChanged(int)), SLOT(resetTimer())); connect(ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(tabHandler(int))); - //connect(monitorUpdater, SIGNAL(timeout()), SLOT(updateMonitor())); + connect(monitorUpdater, SIGNAL(timeout()), SLOT(updateMonitor())); } MainWindow::~MainWindow()