summaryrefslogtreecommitdiff
authorschurig <schurig>2003-06-06 13:19:33 (UTC)
committer schurig <schurig>2003-06-06 13:19:33 (UTC)
commit78a5ebf10450a99211a5e86be1abc0397b749db3 (patch) (side-by-side diff)
treeb23ff8714bf718cefd1360525fce8a32e688611b
parentfdab8e90076ead49141ed13300e0996ab8dce7da (diff)
downloadopie-78a5ebf10450a99211a5e86be1abc0397b749db3.zip
opie-78a5ebf10450a99211a5e86be1abc0397b749db3.tar.gz
opie-78a5ebf10450a99211a5e86be1abc0397b749db3.tar.bz2
beginnings of cpu frequency changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp61
-rw-r--r--libopie/odevice.h10
2 files changed, 65 insertions, 6 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index f808960..4b5a54e 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -71,8 +71,9 @@ public:
ODirection m_direction;
QValueList <ODeviceButton> *m_buttons;
uint m_holdtime;
+ QStrList *m_cpu_frequencies;
};
class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
@@ -422,8 +423,9 @@ ODevice::ODevice ( )
d-> m_direction = CW;
d-> m_holdtime = 1000; // 1000ms
d-> m_buttons = 0;
+ d-> m_cpu_frequencies = new QStrList;
}
void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
{
@@ -772,8 +774,48 @@ 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;
+}
+
+/**
+ * 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
+
+ return 0;
+}
+
+
+
+/**
* @return a list of hardware buttons
*/
const QValueList <ODeviceButton> &ODevice::buttons ( )
{
@@ -1949,8 +1991,13 @@ 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");
}
bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
{
@@ -2009,8 +2056,9 @@ bool Ramses::setSoftSuspend(bool soft)
bool Ramses::suspend ( )
{
qDebug("Ramses::suspend");
+ return false;
}
/**
* This sets the display on or off
@@ -2047,18 +2095,25 @@ bool Ramses::setDisplayBrightness(int bright)
if (bright > 255 )
bright = 255;
if (bright < 0)
bright = 0;
- bright = 500-(bright * 500 / 255);
+ // Turn backlight completely off
+ if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
+ char writeCommand[10];
+ const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
+ res = (::write(fd, writeCommand, count) != -1);
+ ::close(fd);
+ }
+
+ // scale backlight brightness to hardware
+ bright = 500-(bright * 500 / 255);
if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
qDebug(" %d -> pwm1", bright);
char writeCommand[100];
const int count = sprintf(writeCommand, "%d\n", bright);
res = (::write(fd, writeCommand, count) != -1);
::close(fd);
- } else {
- qWarning("no write");
}
return res;
}
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 0974e8d..7f6f856 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -22,8 +22,9 @@
#include <qobject.h>
#include <qstring.h>
#include <qnamespace.h>
+#include <qstrlist.h>
#include <opie/odevicebutton.h>
#include <qpe/qpeapplication.h> /* for Transformation enum.. */
@@ -148,15 +149,14 @@ protected:
ODeviceData *d;
public:
- // sandman do we want to allow destructions? -zecke?
+ // sandman do we want to allow destructions? -zecke?
virtual ~ODevice ( );
-
static ODevice *inst ( );
-// information
+ // information
QString modelString ( ) const;
OModel model ( ) const;
inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
@@ -197,8 +197,12 @@ public:
virtual bool hasLightSensor ( ) const;
virtual int readLightSensor ( );
virtual int lightSensorResolution ( ) const;
+ QStrList &cpuFrequencies() const;
+ bool setCpuFrequency(uint index);
+ uint 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