From c3b45dd4c55468468c78838155d324450a6d2cad Mon Sep 17 00:00:00 2001 From: marazmista Date: Sun, 2 Jun 2019 12:19:59 +0200 Subject: [PATCH] moved most of daemon initialization stuff from dXorg to radeon_profile class --- radeon-profile/dxorg.cpp | 42 ++++++--------- radeon-profile/dxorg.h | 2 +- radeon-profile/radeon_profile.cpp | 30 ++++++++++- radeon-profile/radeon_profile.h | 2 + radeon-profile/radeon_profile.ui | 88 +++++++++++++++---------------- 5 files changed, 90 insertions(+), 74 deletions(-) diff --git a/radeon-profile/dxorg.cpp b/radeon-profile/dxorg.cpp index 4039339f..7028def7 100644 --- a/radeon-profile/dxorg.cpp +++ b/radeon-profile/dxorg.cpp @@ -30,14 +30,10 @@ void dXorg::configure() { if (radeon_profile::dcomm.isConnected() && globalStuff::globalConfig.daemonData) { qDebug() << "Confguring shared memory for daemon"; setupSharedMem(); - setupDaemon(); + sendSharedMemInfoToDaemon(); } figureOutDriverFeatures(); - - if (features.isFanControlAvailable) - radeon_profile::dcomm.sendCommand(QString().append(DAEMON_SIGNAL_CONFIG).append(SEPARATOR). - append("pwm1_enable").append(SEPARATOR).append(driverFiles.hwmonAttributes.pwm1_enable).append(SEPARATOR)); } void dXorg::setupIoctl() { @@ -77,42 +73,34 @@ void dXorg::setupSharedMem() { // create the shared mem block. The if comes from that configure method // is called on every change gpu, so later, shared mem already exists - if (!sharedMem.isAttached()) { - qDebug() << "Shared memory is not attached, creating it"; - sharedMem.setKey(getRandomString()); + if (sharedMem.isAttached()) + return; - if (!sharedMem.create(SHARED_MEM_SIZE)) { - if (sharedMem.error() == QSharedMemory::AlreadyExists) { - qDebug() << "Shared memory already exists, attaching to it"; + qDebug() << "Shared memory is not attached, creating it"; + sharedMem.setKey(getRandomString()); - if (!sharedMem.attach()) - qCritical() << "Unable to attach to the shared memory: " << sharedMem.errorString(); + if (!sharedMem.create(SHARED_MEM_SIZE)) { + if (sharedMem.error() == QSharedMemory::AlreadyExists) { + qDebug() << "Shared memory already exists, attaching to it"; - } else - qCritical() << "Unable to create the shared memory: " << sharedMem.errorString(); - } + if (!sharedMem.attach()) + qCritical() << "Unable to attach to the shared memory: " << sharedMem.errorString(); + + } else + qCritical() << "Unable to create the shared memory: " << sharedMem.errorString(); } } -void dXorg::setupDaemon() { +void dXorg::sendSharedMemInfoToDaemon() { QString command; command.append(DAEMON_SIGNAL_CONFIG).append(SEPARATOR); command.append("pm_info").append(SEPARATOR).append(driverFiles.debugfs_pm_info).append(SEPARATOR); command.append(DAEMON_SHAREDMEM_KEY).append(SEPARATOR).append(sharedMem.key()).append(SEPARATOR); - if (globalStuff::globalConfig.daemonAutoRefresh) { - command.append(DAEMON_SIGNAL_TIMER_ON).append(SEPARATOR); - command.append(QString::number(globalStuff::globalConfig.interval)).append(SEPARATOR); - } else - command.append(DAEMON_SIGNAL_TIMER_OFF).append(SEPARATOR); - - qDebug() << "Sending daemon config command: " << command; + qDebug() << "Sending daemon shared mem info: " << command; radeon_profile::dcomm.sendCommand(command); } -//bool dXorg::isDaemonConnected() { -//} - void dXorg::figureOutGpuDataFilePaths(const QString &gpuName) { QString devicePath = "/sys/class/drm/" + gpuName + "/device/"; driverFiles.moduleParams = devicePath + "driver/module/parameters/"; diff --git a/radeon-profile/dxorg.h b/radeon-profile/dxorg.h index f8855f67..c4e0b37c 100644 --- a/radeon-profile/dxorg.h +++ b/radeon-profile/dxorg.h @@ -93,7 +93,7 @@ class dXorg void figureOutConstParams(); void setupIoctl(); void setupSharedMem(); - void setupDaemon(); + void sendSharedMemInfoToDaemon(); PowerPlayTable loadPowerPlayTable(const QString &file); QString createDaemonSetCmd(const QString &file, const QString &tableIndex); const std::tuple, QMap> parseOcTable(); diff --git a/radeon-profile/radeon_profile.cpp b/radeon-profile/radeon_profile.cpp index 86f87f95..7eae3586 100644 --- a/radeon-profile/radeon_profile.cpp +++ b/radeon-profile/radeon_profile.cpp @@ -92,9 +92,14 @@ void radeon_profile::initializeDevice() { void radeon_profile::daemonConnected() { qDebug() << "Daemon connected"; - if (!device.isInitialized()) + if (!device.isInitialized()) { + + configureDaemonPreDeviceInit(); initializeDevice(); - else { + configureDaemonPostDeviceInit(); + + } else { + enableUiControls(true); restoreFanState(); } @@ -106,6 +111,27 @@ void radeon_profile::daemonDisconnected() { enableUiControls(false); } +void radeon_profile::configureDaemonPreDeviceInit() { + QString command; + + if (globalStuff::globalConfig.daemonData && globalStuff::globalConfig.daemonAutoRefresh) { + command.append(DAEMON_SIGNAL_TIMER_ON).append(SEPARATOR); + command.append(QString::number(globalStuff::globalConfig.interval)).append(SEPARATOR); + } else + command.append(DAEMON_SIGNAL_TIMER_OFF).append(SEPARATOR); + + dcomm.sendCommand(command); +} + +void radeon_profile::configureDaemonPostDeviceInit() { + QString command; + + if (device.getDriverFeatures().isFanControlAvailable) + command.append(DAEMON_SIGNAL_CONFIG).append(SEPARATOR).append("pwm1_enable").append(SEPARATOR).append(device.getDriverFiles().hwmonAttributes.pwm1_enable).append(SEPARATOR); + + dcomm.sendCommand(command); +} + void radeon_profile::connectSignals() { // fix for warrning: QMetaObject::connectSlotsByName: No matching signal for... diff --git a/radeon-profile/radeon_profile.h b/radeon-profile/radeon_profile.h index 91e749c4..878cef31 100644 --- a/radeon-profile/radeon_profile.h +++ b/radeon-profile/radeon_profile.h @@ -268,6 +268,8 @@ private slots: void restoreFanState(); void addPowerMethodToTrayMenu(const DriverFeatures &features); void initializeDevice(); + void configureDaemonPostDeviceInit(); + void configureDaemonPreDeviceInit(); }; #endif // RADEON_PROFILE_H diff --git a/radeon-profile/radeon_profile.ui b/radeon-profile/radeon_profile.ui index 871b8ebf..c349781c 100644 --- a/radeon-profile/radeon_profile.ui +++ b/radeon-profile/radeon_profile.ui @@ -461,12 +461,12 @@ false - - 190 - 50 + + 190 + Property @@ -552,12 +552,12 @@ QAbstractItemView::ExtendedSelection - - 250 - 100 + + 250 + Connector @@ -605,12 +605,12 @@ QAbstractItemView::NoEditTriggers - - 125 - 50 + + 125 + Option @@ -664,12 +664,12 @@ 2 - - 350 - 100 + + 350 + Power level @@ -2826,12 +2826,12 @@ 5 - - 200 - 50 + + 200 + Name @@ -3655,7 +3655,7 @@ 0 0 895 - 628 + 643 @@ -4416,12 +4416,12 @@ setEnabled(bool) - 214 - 113 + 233 + 108 - 212 - 110 + 233 + 108 @@ -4432,12 +4432,12 @@ setVisible(bool) - 214 - 113 + 233 + 108 - 265 - 110 + 183 + 108 @@ -4480,12 +4480,12 @@ setValue(int) - 204 - 198 + 284 + 155 - 221 - 197 + 284 + 155 @@ -4496,12 +4496,12 @@ setValue(int) - 221 - 197 + 284 + 155 - 204 - 198 + 284 + 155 @@ -4516,8 +4516,8 @@ 181 - 854 - 183 + 1030 + 187 @@ -4528,8 +4528,8 @@ setValue(int) - 854 - 170 + 1030 + 187 802 @@ -4548,8 +4548,8 @@ 222 - 870 - 231 + 1030 + 235 @@ -4560,8 +4560,8 @@ setValue(int) - 855 - 221 + 1030 + 235 756 @@ -4612,8 +4612,8 @@ 130 - 870 - 178 + 1030 + 187 @@ -4660,8 +4660,8 @@ 128 - 865 - 218 + 1030 + 235