mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
add core pstate writing
This commit is contained in:
parent
75d1a3d003
commit
fbdb4f5c51
@ -12,13 +12,18 @@ amdPstateEditor::~amdPstateEditor()
|
|||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
void amdPstateEditor::generateUI(gputypes *types)
|
void amdPstateEditor::grabPointer(gputypes *newtypes)
|
||||||
|
{
|
||||||
|
types = newtypes;
|
||||||
|
}
|
||||||
|
void amdPstateEditor::generateUI()
|
||||||
{
|
{
|
||||||
QWidget *lower = new QWidget;
|
QWidget *lower = new QWidget;
|
||||||
QWidget *upper = new QWidget;
|
QWidget *upper = new QWidget;
|
||||||
QHBoxLayout *ulo = new QHBoxLayout;
|
QHBoxLayout *ulo = new QHBoxLayout;
|
||||||
QHBoxLayout *llo = new QHBoxLayout;
|
QHBoxLayout *llo = new QHBoxLayout;
|
||||||
for (int i=0; i<types->GPUList[0].coreclocks.size(); i++) {
|
for (int i=0; i<types->GPUList[0].coreclocks.size(); i++) {
|
||||||
|
corePstate state;
|
||||||
QGridLayout *glo = new QGridLayout;
|
QGridLayout *glo = new QGridLayout;
|
||||||
QLabel *voltlabel = new QLabel;
|
QLabel *voltlabel = new QLabel;
|
||||||
QLabel *freqlabel = new QLabel;
|
QLabel *freqlabel = new QLabel;
|
||||||
@ -53,10 +58,14 @@ void amdPstateEditor::generateUI(gputypes *types)
|
|||||||
glo->addWidget(voltspinbox, 3, 1);
|
glo->addWidget(voltspinbox, 3, 1);
|
||||||
QWidget *freqsliderowdg = new QWidget;
|
QWidget *freqsliderowdg = new QWidget;
|
||||||
freqsliderowdg->setLayout(glo);
|
freqsliderowdg->setLayout(glo);
|
||||||
llo->addWidget(freqsliderowdg);
|
ulo->addWidget(freqsliderowdg);
|
||||||
|
|
||||||
|
state.voltspinbox = voltspinbox;
|
||||||
|
state.freqspinbox = freqspinbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<types->GPUList[0].memclocks.size(); i++) {
|
for (int i=0; i<types->GPUList[0].memclocks.size(); i++) {
|
||||||
|
memPstate state;
|
||||||
QGridLayout *glo = new QGridLayout;
|
QGridLayout *glo = new QGridLayout;
|
||||||
QLabel *voltlabel = new QLabel;
|
QLabel *voltlabel = new QLabel;
|
||||||
QLabel *freqlabel = new QLabel;
|
QLabel *freqlabel = new QLabel;
|
||||||
@ -91,13 +100,38 @@ void amdPstateEditor::generateUI(gputypes *types)
|
|||||||
glo->addWidget(voltspinbox, 3, 1);
|
glo->addWidget(voltspinbox, 3, 1);
|
||||||
QWidget *freqsliderowdg = new QWidget;
|
QWidget *freqsliderowdg = new QWidget;
|
||||||
freqsliderowdg->setLayout(glo);
|
freqsliderowdg->setLayout(glo);
|
||||||
ulo->addWidget(freqsliderowdg);
|
llo->addWidget(freqsliderowdg);
|
||||||
|
state.voltspinbox = voltspinbox;
|
||||||
|
state.freqspinbox = freqspinbox;
|
||||||
|
memPstates.append(state);
|
||||||
}
|
}
|
||||||
lower->setLayout(ulo);
|
// Add an apply button
|
||||||
upper->setLayout(llo);
|
QPushButton *applyButton = new QPushButton;
|
||||||
|
connect(applyButton, SIGNAL(clicked()), SLOT(applyValues()));
|
||||||
|
applyButton->setText("Apply values");
|
||||||
|
llo->addWidget(applyButton);
|
||||||
|
|
||||||
|
lower->setLayout(llo);
|
||||||
|
upper->setLayout(ulo);
|
||||||
|
|
||||||
QVBoxLayout *mainlo = new QVBoxLayout(this);
|
QVBoxLayout *mainlo = new QVBoxLayout(this);
|
||||||
mainlo->addWidget(upper);
|
mainlo->addWidget(upper);
|
||||||
mainlo->addWidget(lower);
|
mainlo->addWidget(lower);
|
||||||
ui->centralWidget->setLayout(mainlo);
|
ui->centralWidget->setLayout(mainlo);
|
||||||
}
|
}
|
||||||
|
bool amdPstateEditor::applyValues()
|
||||||
|
{
|
||||||
|
qDebug("Applying values");
|
||||||
|
for (int i=0; i<corePstates.size(); i++) {
|
||||||
|
if ((corePstates[i].freqspinbox->value() != types->GPUList[0].coreclocks[i]) || (corePstates[i].voltspinbox->value() != types->GPUList[0].corevolts[i])) {
|
||||||
|
QProcess proc;
|
||||||
|
QString volt = QString::number(corePstates[i].freqspinbox->value());
|
||||||
|
QString freq = QString::number(corePstates[i].voltspinbox->value());
|
||||||
|
proc.start("pkexec echo \"s "+ volt +" "+ freq +"\" "+"> /sys/class/drm/card"+QString::number(types->GPUList[0].fsindex)+"/device/pp_od_clk_voltage");
|
||||||
|
proc.waitForFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QProcess>
|
||||||
#include "gputypes.h"
|
#include "gputypes.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@ -21,10 +23,25 @@ class amdPstateEditor : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit amdPstateEditor(QWidget *parent = nullptr);
|
explicit amdPstateEditor(QWidget *parent = nullptr);
|
||||||
~amdPstateEditor();
|
~amdPstateEditor();
|
||||||
void generateUI(gputypes *types);
|
void grabPointer(gputypes *newtypes);
|
||||||
|
void generateUI();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::amdPstateEditor *ui;
|
Ui::amdPstateEditor *ui;
|
||||||
|
// These are used for getting the values out of the sliders when applying, only a slider or spinbox is required, since they are synced
|
||||||
|
struct memPstate {
|
||||||
|
QSpinBox *voltspinbox;
|
||||||
|
QSpinBox *freqspinbox;
|
||||||
|
};
|
||||||
|
struct corePstate {
|
||||||
|
QSpinBox *voltspinbox;
|
||||||
|
QSpinBox *freqspinbox;
|
||||||
|
};
|
||||||
|
QVector <corePstate> corePstates;
|
||||||
|
QVector <memPstate> memPstates;
|
||||||
|
gputypes *types;
|
||||||
|
private slots:
|
||||||
|
bool applyValues();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AMDPSTATEEDITOR_H
|
#endif // AMDPSTATEEDITOR_H
|
||||||
|
@ -1113,7 +1113,7 @@ void MainWindow::on_GPUComboBox_currentIndexChanged(int index)
|
|||||||
void MainWindow::on_amdPstateButton_pressed()
|
void MainWindow::on_amdPstateButton_pressed()
|
||||||
{
|
{
|
||||||
amdPstateEditor *ps = new amdPstateEditor;
|
amdPstateEditor *ps = new amdPstateEditor;
|
||||||
ps->generateUI(types);
|
ps->grabPointer(types);
|
||||||
ps->setModal(true);
|
ps->setModal(true);
|
||||||
ps->exec();
|
ps->exec();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user