summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/light.cpp30
-rw-r--r--core/settings/light-and-power/light.h3
-rw-r--r--libopie/odevice.cpp49
-rw-r--r--libopie/odevice.h2
4 files changed, 61 insertions, 23 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index 8b98672..68c2929 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -43,4 +43,5 @@
#include <qpushbutton.h>
#include <qgroupbox.h>
+#include <qcombobox.h>
#include <opie/odevice.h>
@@ -63,5 +64,6 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
}
if (m_cres) {
- GroupLight->setTitle(tr("Backlight & Contrast"));
+ GroupLight->setTitle(tr("Backlight && Contrast"));
+ GroupLight_ac->setTitle(GroupLight->title());
} else {
contrast->hide();
@@ -69,4 +71,13 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
}
+ QStrList freq = ODevice::inst()->cpuFrequencies();
+ if ( freq.count() ) {
+ frequency->insertStrList( freq );
+ frequency_ac->insertStrList( freq );
+ } else {
+ frequency->hide();
+ frequency_ac->hide();
+ }
+
Config config ( "apm" );
config. setGroup ( "Battery" );
@@ -78,5 +89,8 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
// battery check and slider
- LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
+ LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
+
+ // CPU frequency
+ frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
int bright = config. readNumEntry ( "Brightness", 127 );
@@ -108,4 +122,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
+ // CPU frequency
+ frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) );
+
bright = config. readNumEntry ( "Brightness", 255 );
brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres ));
@@ -148,4 +165,5 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
}
+ connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
}
@@ -190,4 +208,10 @@ void LightSettings::setContrast ( int contr )
}
+void LightSettings::setFrequency ( int index )
+{
+qWarning("LightSettings::setFrequency(%d)", index);
+ ODevice::inst ( )-> setCpuFrequency(index);
+}
+
void LightSettings::resetBacklight ( )
{
@@ -209,4 +233,5 @@ void LightSettings::accept ( )
if (m_cres)
config. writeEntry ( "Contrast", contrast-> value () );
+ config. writeEntry ( "Freq", frequency->currentItem() );
// ac
@@ -219,4 +244,5 @@ void LightSettings::accept ( )
if (m_cres)
config. writeEntry ( "Contrast", contrast_ac-> value () );
+ config. writeEntry ( "Freq", frequency_ac->currentItem() );
// only make light sensor stuff appear if the unit has a sensor
diff --git a/core/settings/light-and-power/light.h b/core/settings/light-and-power/light.h
index 4a8bf6b..c48e5f6 100644
--- a/core/settings/light-and-power/light.h
+++ b/core/settings/light-and-power/light.h
@@ -31,4 +31,5 @@
#include <qstringlist.h>
+#include <qlistbox.h>
#include "lightsettingsbase.h"
@@ -52,4 +53,5 @@ protected slots:
void setBacklight ( int );
void setContrast ( int );
+ void setFrequency ( int );
void resetBacklight ( );
@@ -58,4 +60,5 @@ private:
int m_cres;
int m_oldcontrast;
+ int m_oldfreq;
QTimer *m_resettimer;
QStringList m_sensordata;
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 4b5a54e..4c33a0e 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -780,5 +780,4 @@ int ODevice::lightSensorResolution ( ) const
QStrList &ODevice::cpuFrequencies ( ) const
{
-qWarning("ODevice::cpuFrequencies: m_cpu_frequencies is %d", (int) d->m_cpu_frequencies);
return *d->m_cpu_frequencies;
}
@@ -798,21 +797,18 @@ bool ODevice::setCpuFrequency(uint index)
qWarning("set freq to %s", freq);
- //TODO: do the change in /proc/sys/cpu/0/speed
-
- return false;
-}
+ int fd;
-/**
- * Returns current frequency index out of d->m_cpu_frequencies
- */
-uint ODevice::cpuFrequency() const
-{
- // TODO: get freq from /proc/sys/cpu/0/speed and return index
+ if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
+ char writeCommand[50];
+ const int count = sprintf(writeCommand, "%s\n", freq);
+ int res = (::write(fd, writeCommand, count) != -1);
+ ::close(fd);
+ return res;
+ }
- return 0;
+ return false;
}
-
/**
* @return a list of hardware buttons
@@ -1993,9 +1989,24 @@ void Ramses::init()
m_power_timer = 0;
-qWarning("adding freq");
- d->m_cpu_frequencies->append("100");
- d->m_cpu_frequencies->append("200");
- d->m_cpu_frequencies->append("300");
- d->m_cpu_frequencies->append("400");
+#ifdef QT_QWS_ALLOW_OVERCLOCK
+#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
+#define OC(x...) x
+#else
+#define OC(x...)
+#endif
+
+
+ // This table is true for a Intel XScale PXA 255
+
+ d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
+OC( d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
+ d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
+OC( d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
+ d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
+OC( d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
+ d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
+ d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
+OC( d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
+
}
@@ -2145,6 +2156,4 @@ bool Ramses::setDisplayContrast(int contr)
res = true;
::close(fd);
- } else {
- qWarning("no write");
}
return res;
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 7f6f856..18ff5f1 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -201,5 +201,5 @@ public:
QStrList &cpuFrequencies() const;
bool setCpuFrequency(uint index);
- uint cpuFrequency() const;
+ int cpuFrequency() const;
/**