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
@@ -33,60 +33,74 @@
#include <qpe/power.h>
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
#include <qpe/qcopenvelope_qws.h>
#endif
#include <qcheckbox.h>
#include <qtabwidget.h>
#include <qslider.h>
#include <qtimer.h>
#include <qspinbox.h>
#include <qpushbutton.h>
#include <qgroupbox.h>
+#include <qcombobox.h>
#include <opie/odevice.h>
#include "sensor.h"
using namespace Opie;
LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
: LightSettingsBase( parent, name, false, WStyle_ContextHelp )
{
m_bres = ODevice::inst ( )-> displayBrightnessResolution ( );
m_cres = ODevice::inst ( )-> displayContrastResolution ( );
if ( !ODevice::inst ( )-> hasLightSensor ( )) {
auto_brightness-> hide ( );
CalibrateLightSensor-> hide ( );
auto_brightness_ac-> hide ( );
CalibrateLightSensor_ac-> hide ( );
}
if (m_cres) {
- GroupLight->setTitle(tr("Backlight & Contrast"));
+ GroupLight->setTitle(tr("Backlight && Contrast"));
+ GroupLight_ac->setTitle(GroupLight->title());
} else {
contrast->hide();
contrast_ac->hide();
}
+ 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" );
// battery spinboxes
interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
// 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 );
int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
brightness-> setTickInterval ( QMAX( 16, 256 / m_bres ));
brightness-> setLineStep ( QMAX( 1, 256 / m_bres ));
brightness-> setPageStep ( QMAX( 1, 256 / m_bres ));
brightness-> setValue ( bright );
if (m_cres) {
contrast-> setTickInterval ( QMAX( 16, 256 / m_cres ));
contrast-> setLineStep ( QMAX( 1, 256 / m_cres ));
contrast-> setPageStep ( QMAX( 1, 256 / m_cres ));
@@ -98,24 +112,27 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
m_sensordata = config. readListEntry ( "LightSensorData", ';' );
config. setGroup ( "AC" );
// ac spinboxes
interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 ));
interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 ));
interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 ));
// ac check and slider
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 ));
brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres ));
brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres ));
brightness_ac-> setValue ( bright );
if (m_cres) {
contr = config. readNumEntry ( "Contrast", 127);
contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres ));
contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres ));
contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres ));
contrast_ac-> setValue ( contr );
@@ -138,24 +155,25 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
tabs-> setCurrentPage ( 0 );
}
else {
tabs-> setCurrentPage ( 1 );
}
connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
if (m_cres) {
connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
}
+ connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
}
LightSettings::~LightSettings ( )
{
}
void LightSettings::calibrateSensor ( )
{
Sensor *s = new Sensor ( m_sensordata, this );
connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
s-> showMaximized ( );
s-> exec ( );
@@ -180,53 +198,61 @@ void LightSettings::setBacklight ( int bright )
m_resettimer-> stop ( );
m_resettimer-> start ( 4000, true );
}
}
void LightSettings::setContrast ( int contr )
{
if (contr == -1) contr = m_oldcontrast;
ODevice::inst ( )-> setDisplayContrast(contr);
}
+void LightSettings::setFrequency ( int index )
+{
+qWarning("LightSettings::setFrequency(%d)", index);
+ ODevice::inst ( )-> setCpuFrequency(index);
+}
+
void LightSettings::resetBacklight ( )
{
setBacklight ( -1 );
setContrast ( -1 );
}
void LightSettings::accept ( )
{
Config config ( "apm" );
// bat
config. setGroup ( "Battery" );
config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
config. writeEntry ( "Dim", interval_dim-> value ( ));
config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
config. writeEntry ( "Suspend", interval_suspend-> value ( ));
config. writeEntry ( "Brightness", brightness-> value () );
if (m_cres)
config. writeEntry ( "Contrast", contrast-> value () );
+ config. writeEntry ( "Freq", frequency->currentItem() );
// ac
config. setGroup ( "AC" );
config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( ));
config. writeEntry ( "Dim", interval_dim_ac-> value ( ));
config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( ));
config. writeEntry ( "Suspend", interval_suspend_ac-> value ( ));
config. writeEntry ( "Brightness", brightness_ac-> value () );
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
if ( ODevice::inst ( )-> hasLightSensor ( )) {
config. setGroup ( "Battery" );
config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
config. writeEntry ( "LightSensorData", m_sensordata, ';' );
config. setGroup ( "AC" );
config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() );
config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' );
}
// advanced
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
@@ -21,47 +21,50 @@
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __LIGHT_H__
#define __LIGHT_H__
#include <qstringlist.h>
+#include <qlistbox.h>
#include "lightsettingsbase.h"
class QTimer;
class LightSettings : public LightSettingsBase
{
Q_OBJECT
public:
LightSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~LightSettings();
protected:
virtual void accept();
virtual void done ( int r );
protected slots:
virtual void calibrateSensor ( );
virtual void calibrateSensorAC ( );
void setBacklight ( int );
void setContrast ( int );
+ void setFrequency ( int );
void resetBacklight ( );
private:
int m_bres;
int m_cres;
int m_oldcontrast;
+ int m_oldfreq;
QTimer *m_resettimer;
QStringList m_sensordata;
QStringList m_sensordata_ac;
};
#endif
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 4b5a54e..4c33a0e 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -770,59 +770,55 @@ int ODevice::readLightSensor ( )
* @return the light sensor resolution whatever that is ;)
*/
int ODevice::lightSensorResolution ( ) const
{
return 0;
}
/**
* @return a list with valid CPU frequency
*/
QStrList &ODevice::cpuFrequencies ( ) const
{
-qWarning("ODevice::cpuFrequencies: m_cpu_frequencies is %d", (int) d->m_cpu_frequencies);
return *d->m_cpu_frequencies;
}
/**
* Set desired cpu frequency
*
* @param index index into d->m_cpu_frequencies of the frequency to be set
*/
bool ODevice::setCpuFrequency(uint index)
{
if (index >= d->m_cpu_frequencies->count())
return false;
char *freq = d->m_cpu_frequencies->at(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
*/
const QValueList <ODeviceButton> &ODevice::buttons ( )
{
initButtons ( );
return *d-> m_buttons;
}
/**
* @return The amount of time that would count as a hold
@@ -1983,29 +1979,44 @@ void Ramses::init()
if (f.open(IO_ReadOnly)) {
d->m_systemstr = "OpenEmbedded/Ramses";
d->m_system = System_OpenZaurus;
QTextStream ts(&f);
ts.setDevice(&f);
d->m_sysverstr = ts.readLine();
f.close();
}
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
+
}
bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
{
Q_UNUSED( keycode );
Q_UNUSED( modifiers );
Q_UNUSED( isPress );
Q_UNUSED( autoRepeat );
return false;
}
void Ramses::timerEvent(QTimerEvent *)
@@ -2135,23 +2146,21 @@ bool Ramses::setDisplayContrast(int contr)
contr = 255;
if (contr < 0)
contr = 0;
contr = 90 - (contr * 20 / 255);
if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
qDebug(" %d -> pwm0", contr);
char writeCommand[100];
const int count = sprintf(writeCommand, "%d\n", contr);
res = (::write(fd, writeCommand, count) != -1);
res = true;
::close(fd);
- } else {
- qWarning("no write");
}
return res;
}
int Ramses::displayContrastResolution() const
{
return 20;
}
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 7f6f856..18ff5f1 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -191,25 +191,25 @@ public:
virtual QValueList <OLed> ledList ( ) const;
virtual QValueList <OLedState> ledStateList ( OLed led ) const;
virtual OLedState ledState ( OLed led ) const;
virtual bool setLedState ( OLed led, OLedState st );
virtual bool hasLightSensor ( ) const;
virtual int readLightSensor ( );
virtual int lightSensorResolution ( ) const;
QStrList &cpuFrequencies() const;
bool setCpuFrequency(uint index);
- uint cpuFrequency() const;
+ int cpuFrequency() const;
/**
* Returns the available buttons on this device. The number and location
* of buttons will vary depending on the device. Button numbers will be assigned
* by the device manufacturer and will be from most preferred button to least preffered
* button. Note that this list only contains "user mappable" buttons.
*/
const QValueList<ODeviceButton> &buttons ( );
/**
* Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
* returns 0L