From kde-devel Sun Mar 07 22:57:37 2010 From: Holger Macht Date: Sun, 07 Mar 2010 22:57:37 +0000 To: kde-devel Subject: [PATCH] powerdevil-remove-cpufreq.patch Message-Id: <4B942F61.8050708 () homac ! de> X-MARC-Message: https://marc.info/?l=kde-devel&m=126800277431817 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------050703060501090900010100" This is a multi-part message in MIME format. --------------050703060501090900010100 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Remove all CPU frequency scaling code from powerdevil and the kcm module. You should never offer those options to the user because he might not understand what the impact is. You only want a dynamic frequency algorithm which is the default these days (ondemand governor). A good explanation is provided in [1]. Regards, Holger --------------050703060501090900010100 Content-Type: text/x-patch; name="powerdevil-remove-cpufreq.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="powerdevil-remove-cpufreq.patch" Index: KDE/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.cpp =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.cpp +++ KDE/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.cpp @@ -360,8 +360,6 @@ void PowerDevilDaemon::applyProfile() Solid::Control::PowerManager::setBrightness(settings->readEntry("brightness").toInt()); d->brightness = settings->readEntry("brightness").toInt(); - Solid::Control::PowerManager::setCpuFreqPolicy((Solid::Control::PowerManager::CpuFreqPolicy) - settings->readEntry("cpuPolicy").toInt()); QVariant var = settings->readEntry("disabledCPUs", QVariant()); QList list = var.toList(); @@ -1169,36 +1167,6 @@ void PowerDevilDaemon::streamData() emit stateChanged(d->batteryPercent, d->isPlugged); } -QVariantMap PowerDevilDaemon::getSupportedGovernors() -{ - QVariantMap retlist; - - Solid::Control::PowerManager::CpuFreqPolicies policies = - Solid::Control::PowerManager::supportedCpuFreqPolicies(); - - if (policies & Solid::Control::PowerManager::Performance) { - retlist[i18n("Performance")] = (int) Solid::Control::PowerManager::Performance; - } - - if (policies & Solid::Control::PowerManager::OnDemand) { - retlist[i18n("Dynamic (ondemand)")] = (int) Solid::Control::PowerManager::OnDemand; - } - - if (policies & Solid::Control::PowerManager::Conservative) { - retlist[i18n("Dynamic (conservative)")] = (int) Solid::Control::PowerManager::Conservative; - } - - if (policies & Solid::Control::PowerManager::Powersave) { - retlist[i18n("Powersave")] = (int) Solid::Control::PowerManager::Powersave; - } - - if (policies & Solid::Control::PowerManager::Userspace) { - retlist[i18n("Userspace")] = (int) Solid::Control::PowerManager::Userspace; - } - - return retlist; -} - QVariantMap PowerDevilDaemon::getSupportedSuspendMethods() { QVariantMap retlist; @@ -1235,15 +1203,6 @@ void PowerDevilDaemon::setPowersavingSch Solid::Control::PowerManager::setScheme(scheme); } -void PowerDevilDaemon::setGovernor(int governor) -{ - if (!checkIfCurrentSessionActive()) { - return; - } - - Solid::Control::PowerManager::setCpuFreqPolicy((Solid::Control::PowerManager::CpuFreqPolicy) governor); -} - void PowerDevilDaemon::suspend(int method) { if (!checkIfCurrentSessionActive()) { Index: KDE/kdebase/workspace/powerdevil/daemon/org.kde.PowerDevil.xml =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/daemon/org.kde.PowerDevil.xml +++ KDE/kdebase/workspace/powerdevil/daemon/org.kde.PowerDevil.xml @@ -16,9 +16,6 @@ - - - @@ -30,10 +27,6 @@ - - - - Index: KDE/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.h =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.h +++ KDE/kdebase/workspace/powerdevil/daemon/PowerDevilDaemon.h @@ -45,7 +45,6 @@ public Q_SLOTS: void reloadAndStream(); void streamData(); - void setGovernor(int governor); void suspend(int method); void setPowersavingScheme(const QString &scheme); void setBrightness(int value); @@ -55,7 +54,6 @@ public Q_SLOTS: deleteLater(); } - QVariantMap getSupportedGovernors(); QStringList getSupportedSchemes(); QVariantMap getSupportedSuspendMethods(); Index: KDE/kdebase/workspace/powerdevil/kcmodule/profileEditPage.ui =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/kcmodule/profileEditPage.ui +++ KDE/kdebase/workspace/powerdevil/kcmodule/profileEditPage.ui @@ -45,7 +45,7 @@ - 0 + 2 @@ -478,45 +478,17 @@ - - - - - - - CPU Behaviour strongly impacts on your system performance and on your battery's life. Here you can choose the policy best suitable for this profile - - - CPU frequency scaling policy: - - - false - - - freqCombo - - + + - - - - - 0 - 0 - - - - - 250 - 16777215 - - - - CPU Behaviour strongly impacts on your system performance and on your battery's life. Here you can choose the policy best suitable for this profile + + + + Qt::Horizontal - + System powersaving scheme: @@ -526,7 +498,7 @@ - + @@ -542,7 +514,7 @@ - + When loading profile execute: @@ -552,7 +524,7 @@ - + @@ -568,23 +540,11 @@ - - - - Qt::Horizontal - - - - - - line_5 schemeCombo - PoweredFreqLabel_2 label_12 label_20 - freqCombo label_19 scriptRequester Index: KDE/kdebase/workspace/powerdevil/kcmodule/EditPage.cpp =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/kcmodule/EditPage.cpp +++ KDE/kdebase/workspace/powerdevil/kcmodule/EditPage.cpp @@ -59,7 +59,6 @@ EditPage::EditPage(QWidget *parent) KConfigGroup *performance = new KConfigGroup(m_profilesConfig, "Performance"); performance->writeEntry("brightness", 100); - performance->writeEntry("cpuPolicy", (int) Solid::Control::PowerManager::Performance); performance->writeEntry("idleAction", 0); performance->writeEntry("idleTime", 50); performance->writeEntry("lidAction", 0); @@ -144,33 +143,6 @@ void EditPage::fillUi() powerButtonCombo->addItem(KIcon("system-suspend"), i18n("Standby"), (int) Standby); } - Solid::Control::PowerManager::CpuFreqPolicies policies = Solid::Control::PowerManager::supportedCpuFreqPolicies(); - - if (policies & Solid::Control::PowerManager::Performance) { - freqCombo->addItem(KIcon("preferences-system-performance"), i18n("Performance"), - (int) Solid::Control::PowerManager::Performance); - } - - if (policies & Solid::Control::PowerManager::OnDemand) { - freqCombo->addItem(KIcon("system-switch-user"), - i18n("Dynamic (ondemand)"), (int) Solid::Control::PowerManager::OnDemand); - } - - if (policies & Solid::Control::PowerManager::Conservative) { - freqCombo->addItem(KIcon("user-invisible"), i18n("Dynamic (conservative)"), - (int) Solid::Control::PowerManager::Conservative); - } - - if (policies & Solid::Control::PowerManager::Powersave) { - freqCombo->addItem(KIcon("preferences-system-power-management"), i18n("Powersave"), - (int) Solid::Control::PowerManager::Powersave); - } - - if (policies & Solid::Control::PowerManager::Userspace) { - freqCombo->addItem(KIcon("kuser"), i18n("Userspace"), - (int) Solid::Control::PowerManager::Userspace); - } - schemeCombo->addItems(Solid::Control::PowerManager::supportedSchemes()); foreach(const Solid::Device &device, Solid::Device::listFromType(Solid::DeviceInterface::Processor, QString())) { @@ -222,7 +194,6 @@ void EditPage::fillUi() connect(dimOnIdleTime, SIGNAL(valueChanged(int)), SLOT(setProfileChanged())); connect(idleTime, SIGNAL(valueChanged(int)), SLOT(setProfileChanged())); connect(idleCombo, SIGNAL(currentIndexChanged(int)), SLOT(setProfileChanged())); - connect(freqCombo, SIGNAL(currentIndexChanged(int)), SLOT(setProfileChanged())); connect(laptopClosedCombo, SIGNAL(currentIndexChanged(int)), SLOT(setProfileChanged())); connect(sleepButtonCombo, SIGNAL(currentIndexChanged(int)), SLOT(setProfileChanged())); connect(powerButtonCombo, SIGNAL(currentIndexChanged(int)), SLOT(setProfileChanged())); @@ -322,7 +293,6 @@ void EditPage::loadProfile() dimOnIdleTime->setValue(group->readEntry("dimOnIdleTime").toInt()); idleTime->setValue(group->readEntry("idleTime").toInt()); idleCombo->setCurrentIndex(idleCombo->findData(group->readEntry("idleAction").toInt())); - freqCombo->setCurrentIndex(freqCombo->findData(group->readEntry("cpuPolicy").toInt())); schemeCombo->setCurrentIndex(schemeCombo->findText(group->readEntry("scheme"))); scriptRequester->setUrl(KUrl::fromPath(group->readEntry("scriptpath"))); @@ -380,7 +350,6 @@ void EditPage::saveProfile(const QString } group->writeEntry("brightness", brightnessSlider->value()); - group->writeEntry("cpuPolicy", freqCombo->itemData(freqCombo->currentIndex()).toInt()); group->writeEntry("dimOnIdle", dimDisplayOnIdle->isChecked()); group->writeEntry("dimOnIdleTime", dimOnIdleTime->value()); group->writeEntry("idleAction", idleCombo->itemData(idleCombo->currentIndex()).toInt()); @@ -472,7 +441,6 @@ void EditPage::createProfile(const QStri KConfigGroup *group = new KConfigGroup(m_profilesConfig, name); group->writeEntry("brightness", 80); - group->writeEntry("cpuPolicy", (int) Solid::Control::PowerManager::Powersave); group->writeEntry("idleAction", 0); group->writeEntry("idleTime", 50); group->writeEntry("lidAction", 0); Index: KDE/kdebase/workspace/powerdevil/kcmodule/CapabilitiesPage.cpp =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/kcmodule/CapabilitiesPage.cpp +++ KDE/kdebase/workspace/powerdevil/kcmodule/CapabilitiesPage.cpp @@ -144,40 +144,6 @@ void CapabilitiesPage::fillCapabilities( supportedMethods->setText(sMethods); - QString scMethods; - - Solid::Control::PowerManager::CpuFreqPolicies policies = Solid::Control::PowerManager::supportedCpuFreqPolicies(); - - if (policies & Solid::Control::PowerManager::Performance) { - scMethods.append(QString(i18n("Performance") + QString(", "))); - } - - if (policies & Solid::Control::PowerManager::OnDemand) { - scMethods.append(QString(i18n("Dynamic (ondemand)") + QString(", "))); - } - - if (policies & Solid::Control::PowerManager::Conservative) { - scMethods.append(QString(i18n("Dynamic (conservative)") + QString(", "))); - } - - if (policies & Solid::Control::PowerManager::Powersave) { - scMethods.append(QString(i18n("Powersave") + QString(", "))); - } - - if (policies & Solid::Control::PowerManager::Userspace) { - scMethods.append(QString(i18n("Userspace") + QString(", "))); - } - - if (!scMethods.isEmpty()) { - scMethods.remove(scMethods.length() - 2, 2); - isScalingSupported->setPixmap(KIcon("dialog-ok-apply").pixmap(16, 16)); - } else { - scMethods = i18nc("None", "No methods found"); - isScalingSupported->setPixmap(KIcon("dialog-cancel").pixmap(16, 16)); - } - - supportedPolicies->setText(scMethods); - if (!Solid::Control::PowerManager::supportedSchemes().isEmpty()) { isSchemeSupported->setPixmap(KIcon("dialog-ok-apply").pixmap(16, 16)); } else { @@ -254,19 +220,7 @@ void CapabilitiesPage::fillCapabilities( ent->deleteLater(); } - if ((scMethods.isEmpty() || scMethods == i18n("Performance")) && - PowerDevilSettings::scalingWarning()) { - setIssue(true, i18n("No scaling methods were found. If your CPU is reasonably recent, this " - "is probably because you have not loaded some kernel modules. Usually " - "scaling modules have names similar to cpufreq_ondemand. Scaling is " - "useful and can save a lot of battery. Click on \"Attempt Loading Modules\" " - "to let PowerDevil try to load the required modules. If you are sure your PC " - "does not support scaling, you can also disable this warning by clicking " - "\"Do not display this warning again\"."), - i18n("Attempt to load modules"), "system-run", SLOT(attemptLoadingModules()), - i18n("Do not display this warning again"), "dialog-ok-apply", SLOT(disableScalingWarn())); - - } else if (!ck) { + if (!ck) { setIssue(true, i18n("ConsoleKit was not found active on your PC, or PowerDevil cannot contact it. " "ConsoleKit lets PowerDevil detect whether the current session is active, which is " "useful if you have more than one user logged into your system at any one time.")); @@ -341,57 +295,6 @@ void CapabilitiesPage::setIssue(bool iss statusLayout->addLayout(ly); } -void CapabilitiesPage::disableScalingWarn() -{ - PowerDevilSettings::setScalingWarning(false); - - emit reload(); - emit reloadModule(); -} - -void CapabilitiesPage::attemptLoadingModules() -{ - // Let's check what we have - - QProcess process; - - process.start("modprobe -l"); - process.waitForFinished(); - - QStringList modules; - - foreach(const QString &ent, process.readAll().split('\n')) { - if (ent.contains("cpufreq_") || ent.contains("ondemand")) { - QStringList ents = ent.split('/'); - QString module = ents.at(ents.count() - 1); - module.remove(module.length() - 3, 3); - modules.append(module); - } - } - - if (modules.isEmpty()) { - KMessageBox::sorry(this, i18n("No kernel modules for CPU scaling were found. Either you do not " - "have them installed, or PowerDevil could not detect them."), - i18n("Modules not found")); - return; - } - - QString command = "kdesu '"; - - foreach(const QString &ent, modules) { - command.append(QString("modprobe %1 | ").arg(ent)); - } - - command.remove(command.length() - 3, 3); - - command.append('\''); - - system(command.toAscii().data()); - - emit reload(); - emit reloadModule(); -} - void CapabilitiesPage::enableXSync() { PowerDevilSettings::setPollingSystem(2); Index: KDE/kdebase/workspace/powerdevil/kcmodule/CapabilitiesPage.h =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/kcmodule/CapabilitiesPage.h +++ KDE/kdebase/workspace/powerdevil/kcmodule/CapabilitiesPage.h @@ -38,8 +38,6 @@ public: private slots: void fillCapabilities(); void enableXSync(); - void disableScalingWarn(); - void attemptLoadingModules(); private: void setIssue(bool issue, const QString &text = QString(), Index: KDE/kdebase/workspace/powerdevil/default.powerdevilprofiles =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/default.powerdevilprofiles +++ KDE/kdebase/workspace/powerdevil/default.powerdevilprofiles @@ -7,7 +7,6 @@ DPMSStandbyEnabled=true DPMSSuspend=15 DPMSSuspendEnabled=true brightness=38 -cpuPolicy=4 dimOnIdle=true dimOnIdleTime=5 disableCompositing=true @@ -33,7 +32,6 @@ DPMSStandbyEnabled=true DPMSSuspend=30 DPMSSuspendEnabled=true brightness=100 -cpuPolicy=1 dimOnIdle=false dimOnIdleTime=1 disableCompositing=false @@ -59,7 +57,6 @@ DPMSStandbyEnabled=true DPMSSuspend=20 DPMSSuspendEnabled=true brightness=62 -cpuPolicy=1 dimOnIdle=true dimOnIdleTime=10 disableCompositing=false @@ -85,7 +82,6 @@ DPMSStandbyEnabled=false DPMSSuspend=0 DPMSSuspendEnabled=false brightness=100 -cpuPolicy=1 dimOnIdle=false dimOnIdleTime=1 disableCompositing=false @@ -110,7 +106,6 @@ DPMSStandbyEnabled=true DPMSSuspend=10 DPMSSuspendEnabled=true brightness=13 -cpuPolicy=4 dimOnIdle=true dimOnIdleTime=1 disableCompositing=true Index: KDE/kdebase/workspace/powerdevil/kcmodule/capabilitiesPage.ui =================================================================== --- KDE.orig/kdebase/workspace/powerdevil/kcmodule/capabilitiesPage.ui +++ KDE/kdebase/workspace/powerdevil/kcmodule/capabilitiesPage.ui @@ -93,54 +93,20 @@ - - - Scaling capability - - - - - - - - - - - Qt::Horizontal - - - - Supported CPU Policies - - - - - - - - - - true - - - true - - - - + Supported suspend methods - + @@ -153,28 +119,28 @@ - + Supported schemes - + - + Qt::Horizontal - + Support for DPMS @@ -187,14 +153,14 @@ - + - + Checks if ConsoleKit is active on your system @@ -207,28 +173,28 @@ - + - + Qt::Horizontal - + Status - + --------------050703060501090900010100 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << --------------050703060501090900010100--