Skip to content

Commit

Permalink
moved most of daemon initialization stuff from dXorg to radeon_profile
Browse files Browse the repository at this point in the history
class
  • Loading branch information
marazmista committed Jun 2, 2019
1 parent 8e5ef9f commit c3b45dd
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 74 deletions.
42 changes: 15 additions & 27 deletions radeon-profile/dxorg.cpp
Expand Up @@ -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() {
Expand Down Expand Up @@ -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/";
Expand Down
2 changes: 1 addition & 1 deletion radeon-profile/dxorg.h
Expand Up @@ -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<QString, FVTable>, QMap<QString, OCRange>> parseOcTable();
Expand Down
30 changes: 28 additions & 2 deletions radeon-profile/radeon_profile.cpp
Expand Up @@ -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();
}
Expand All @@ -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...
Expand Down
2 changes: 2 additions & 0 deletions radeon-profile/radeon_profile.h
Expand Up @@ -268,6 +268,8 @@ private slots:
void restoreFanState();
void addPowerMethodToTrayMenu(const DriverFeatures &features);
void initializeDevice();
void configureDaemonPostDeviceInit();
void configureDaemonPreDeviceInit();
};

#endif // RADEON_PROFILE_H
88 changes: 44 additions & 44 deletions radeon-profile/radeon_profile.ui
Expand Up @@ -461,12 +461,12 @@
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>190</number>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>190</number>
</attribute>
<column>
<property name="text">
<string>Property</string>
Expand Down Expand Up @@ -552,12 +552,12 @@
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<attribute name="headerDefaultSectionSize">
<number>250</number>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>100</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>250</number>
</attribute>
<column>
<property name="text">
<string>Connector</string>
Expand Down Expand Up @@ -605,12 +605,12 @@
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<attribute name="headerDefaultSectionSize">
<number>125</number>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>125</number>
</attribute>
<column>
<property name="text">
<string>Option</string>
Expand Down Expand Up @@ -664,12 +664,12 @@
<property name="indentation">
<number>2</number>
</property>
<attribute name="headerDefaultSectionSize">
<number>350</number>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>100</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>350</number>
</attribute>
<column>
<property name="text">
<string>Power level</string>
Expand Down Expand Up @@ -2826,12 +2826,12 @@
<property name="indentation">
<number>5</number>
</property>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<column>
<property name="text">
<string>Name</string>
Expand Down Expand Up @@ -3655,7 +3655,7 @@
<x>0</x>
<y>0</y>
<width>895</width>
<height>628</height>
<height>643</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
Expand Down Expand Up @@ -4416,12 +4416,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>214</x>
<y>113</y>
<x>233</x>
<y>108</y>
</hint>
<hint type="destinationlabel">
<x>212</x>
<y>110</y>
<x>233</x>
<y>108</y>
</hint>
</hints>
</connection>
Expand All @@ -4432,12 +4432,12 @@
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>214</x>
<y>113</y>
<x>233</x>
<y>108</y>
</hint>
<hint type="destinationlabel">
<x>265</x>
<y>110</y>
<x>183</x>
<y>108</y>
</hint>
</hints>
</connection>
Expand Down Expand Up @@ -4480,12 +4480,12 @@
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>204</x>
<y>198</y>
<x>284</x>
<y>155</y>
</hint>
<hint type="destinationlabel">
<x>221</x>
<y>197</y>
<x>284</x>
<y>155</y>
</hint>
</hints>
</connection>
Expand All @@ -4496,12 +4496,12 @@
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>221</x>
<y>197</y>
<x>284</x>
<y>155</y>
</hint>
<hint type="destinationlabel">
<x>204</x>
<y>198</y>
<x>284</x>
<y>155</y>
</hint>
</hints>
</connection>
Expand All @@ -4516,8 +4516,8 @@
<y>181</y>
</hint>
<hint type="destinationlabel">
<x>854</x>
<y>183</y>
<x>1030</x>
<y>187</y>
</hint>
</hints>
</connection>
Expand All @@ -4528,8 +4528,8 @@
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>854</x>
<y>170</y>
<x>1030</x>
<y>187</y>
</hint>
<hint type="destinationlabel">
<x>802</x>
Expand All @@ -4548,8 +4548,8 @@
<y>222</y>
</hint>
<hint type="destinationlabel">
<x>870</x>
<y>231</y>
<x>1030</x>
<y>235</y>
</hint>
</hints>
</connection>
Expand All @@ -4560,8 +4560,8 @@
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>855</x>
<y>221</y>
<x>1030</x>
<y>235</y>
</hint>
<hint type="destinationlabel">
<x>756</x>
Expand Down Expand Up @@ -4612,8 +4612,8 @@
<y>130</y>
</hint>
<hint type="destinationlabel">
<x>870</x>
<y>178</y>
<x>1030</x>
<y>187</y>
</hint>
</hints>
</connection>
Expand Down Expand Up @@ -4660,8 +4660,8 @@
<y>128</y>
</hint>
<hint type="destinationlabel">
<x>865</x>
<y>218</y>
<x>1030</x>
<y>235</y>
</hint>
</hints>
</connection>
Expand Down

0 comments on commit c3b45dd

Please sign in to comment.