author | schurig <schurig> | 2003-06-06 14:32:51 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-06 14:32:51 (UTC) |
commit | 802e9457b1bc158c61849755215fe2a5bad6231d (patch) (unidiff) | |
tree | 81b8a5cdb9d4b5beaee2f18eec6ca995ec8e77d2 | |
parent | 225486a1c3714b4b0c0e60286df13d8ede029768 (diff) | |
download | opie-802e9457b1bc158c61849755215fe2a5bad6231d.zip opie-802e9457b1bc158c61849755215fe2a5bad6231d.tar.gz opie-802e9457b1bc158c61849755215fe2a5bad6231d.tar.bz2 |
frequency change works now
-rw-r--r-- | core/settings/light-and-power/light.cpp | 28 | ||||
-rw-r--r-- | core/settings/light-and-power/light.h | 3 | ||||
-rw-r--r-- | libopie/odevice.cpp | 47 | ||||
-rw-r--r-- | libopie/odevice.h | 2 |
4 files changed, 59 insertions, 21 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 @@ | |||
43 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
44 | #include <qgroupbox.h> | 44 | #include <qgroupbox.h> |
45 | #include <qcombobox.h> | ||
45 | 46 | ||
46 | #include <opie/odevice.h> | 47 | #include <opie/odevice.h> |
@@ -63,5 +64,6 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
63 | } | 64 | } |
64 | if (m_cres) { | 65 | if (m_cres) { |
65 | GroupLight->setTitle(tr("Backlight & Contrast")); | 66 | GroupLight->setTitle(tr("Backlight && Contrast")); |
67 | GroupLight_ac->setTitle(GroupLight->title()); | ||
66 | } else { | 68 | } else { |
67 | contrast->hide(); | 69 | contrast->hide(); |
@@ -69,4 +71,13 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
69 | } | 71 | } |
70 | 72 | ||
73 | QStrList freq = ODevice::inst()->cpuFrequencies(); | ||
74 | if ( freq.count() ) { | ||
75 | frequency->insertStrList( freq ); | ||
76 | frequency_ac->insertStrList( freq ); | ||
77 | } else { | ||
78 | frequency->hide(); | ||
79 | frequency_ac->hide(); | ||
80 | } | ||
81 | |||
71 | Config config ( "apm" ); | 82 | Config config ( "apm" ); |
72 | config. setGroup ( "Battery" ); | 83 | config. setGroup ( "Battery" ); |
@@ -80,4 +91,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
80 | LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 91 | LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
81 | 92 | ||
93 | // CPU frequency | ||
94 | frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); | ||
95 | |||
82 | int bright = config. readNumEntry ( "Brightness", 127 ); | 96 | int bright = config. readNumEntry ( "Brightness", 127 ); |
83 | int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); | 97 | int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); |
@@ -108,4 +122,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
108 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 122 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
109 | 123 | ||
124 | // CPU frequency | ||
125 | frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); | ||
126 | |||
110 | bright = config. readNumEntry ( "Brightness", 255 ); | 127 | bright = config. readNumEntry ( "Brightness", 255 ); |
111 | brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); | 128 | brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); |
@@ -148,4 +165,5 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
148 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | 165 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); |
149 | } | 166 | } |
167 | connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); | ||
150 | } | 168 | } |
151 | 169 | ||
@@ -190,4 +208,10 @@ void LightSettings::setContrast ( int contr ) | |||
190 | } | 208 | } |
191 | 209 | ||
210 | void LightSettings::setFrequency ( int index ) | ||
211 | { | ||
212 | qWarning("LightSettings::setFrequency(%d)", index); | ||
213 | ODevice::inst ( )-> setCpuFrequency(index); | ||
214 | } | ||
215 | |||
192 | void LightSettings::resetBacklight ( ) | 216 | void LightSettings::resetBacklight ( ) |
193 | { | 217 | { |
@@ -209,4 +233,5 @@ void LightSettings::accept ( ) | |||
209 | if (m_cres) | 233 | if (m_cres) |
210 | config. writeEntry ( "Contrast", contrast-> value () ); | 234 | config. writeEntry ( "Contrast", contrast-> value () ); |
235 | config. writeEntry ( "Freq", frequency->currentItem() ); | ||
211 | 236 | ||
212 | // ac | 237 | // ac |
@@ -219,4 +244,5 @@ void LightSettings::accept ( ) | |||
219 | if (m_cres) | 244 | if (m_cres) |
220 | config. writeEntry ( "Contrast", contrast_ac-> value () ); | 245 | config. writeEntry ( "Contrast", contrast_ac-> value () ); |
246 | config. writeEntry ( "Freq", frequency_ac->currentItem() ); | ||
221 | 247 | ||
222 | // only make light sensor stuff appear if the unit has a sensor | 248 | // 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 @@ | |||
31 | 31 | ||
32 | #include <qstringlist.h> | 32 | #include <qstringlist.h> |
33 | #include <qlistbox.h> | ||
33 | #include "lightsettingsbase.h" | 34 | #include "lightsettingsbase.h" |
34 | 35 | ||
@@ -52,4 +53,5 @@ protected slots: | |||
52 | void setBacklight ( int ); | 53 | void setBacklight ( int ); |
53 | void setContrast ( int ); | 54 | void setContrast ( int ); |
55 | void setFrequency ( int ); | ||
54 | void resetBacklight ( ); | 56 | void resetBacklight ( ); |
55 | 57 | ||
@@ -58,4 +60,5 @@ private: | |||
58 | int m_cres; | 60 | int m_cres; |
59 | int m_oldcontrast; | 61 | int m_oldcontrast; |
62 | int m_oldfreq; | ||
60 | QTimer *m_resettimer; | 63 | QTimer *m_resettimer; |
61 | QStringList m_sensordata; | 64 | 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 | |||
780 | QStrList &ODevice::cpuFrequencies ( ) const | 780 | QStrList &ODevice::cpuFrequencies ( ) const |
781 | { | 781 | { |
782 | qWarning("ODevice::cpuFrequencies: m_cpu_frequencies is %d", (int) d->m_cpu_frequencies); | ||
783 | return *d->m_cpu_frequencies; | 782 | return *d->m_cpu_frequencies; |
784 | } | 783 | } |
@@ -798,21 +797,18 @@ bool ODevice::setCpuFrequency(uint index) | |||
798 | qWarning("set freq to %s", freq); | 797 | qWarning("set freq to %s", freq); |
799 | 798 | ||
800 | //TODO: do the change in /proc/sys/cpu/0/speed | 799 | int fd; |
801 | 800 | ||
802 | return false; | 801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
802 | char writeCommand[50]; | ||
803 | const int count = sprintf(writeCommand, "%s\n", freq); | ||
804 | int res = (::write(fd, writeCommand, count) != -1); | ||
805 | ::close(fd); | ||
806 | return res; | ||
803 | } | 807 | } |
804 | 808 | ||
805 | /** | 809 | return false; |
806 | * Returns current frequency index out of d->m_cpu_frequencies | ||
807 | */ | ||
808 | uint ODevice::cpuFrequency() const | ||
809 | { | ||
810 | // TODO: get freq from /proc/sys/cpu/0/speed and return index | ||
811 | |||
812 | return 0; | ||
813 | } | 810 | } |
814 | 811 | ||
815 | 812 | ||
816 | |||
817 | /** | 813 | /** |
818 | * @return a list of hardware buttons | 814 | * @return a list of hardware buttons |
@@ -1993,9 +1989,24 @@ void Ramses::init() | |||
1993 | m_power_timer = 0; | 1989 | m_power_timer = 0; |
1994 | 1990 | ||
1995 | qWarning("adding freq"); | 1991 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
1996 | d->m_cpu_frequencies->append("100"); | 1992 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
1997 | d->m_cpu_frequencies->append("200"); | 1993 | #define OC(x...) x |
1998 | d->m_cpu_frequencies->append("300"); | 1994 | #else |
1999 | d->m_cpu_frequencies->append("400"); | 1995 | #define OC(x...) |
1996 | #endif | ||
1997 | |||
1998 | |||
1999 | // This table is true for a Intel XScale PXA 255 | ||
2000 | |||
2001 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | ||
2002 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | ||
2003 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | ||
2004 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | ||
2005 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | ||
2006 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | ||
2007 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | ||
2008 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | ||
2009 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | ||
2010 | |||
2000 | } | 2011 | } |
2001 | 2012 | ||
@@ -2145,6 +2156,4 @@ bool Ramses::setDisplayContrast(int contr) | |||
2145 | res = true; | 2156 | res = true; |
2146 | ::close(fd); | 2157 | ::close(fd); |
2147 | } else { | ||
2148 | qWarning("no write"); | ||
2149 | } | 2158 | } |
2150 | return res; | 2159 | 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: | |||
201 | QStrList &cpuFrequencies() const; | 201 | QStrList &cpuFrequencies() const; |
202 | bool setCpuFrequency(uint index); | 202 | bool setCpuFrequency(uint index); |
203 | uint cpuFrequency() const; | 203 | int cpuFrequency() const; |
204 | 204 | ||
205 | /** | 205 | /** |