summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/odevice.cpp61
-rw-r--r--libopie/odevice.h6
2 files changed, 63 insertions, 4 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index f808960..4b5a54e 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -74,2 +74,3 @@ public:
uint m_holdtime;
+ QStrList *m_cpu_frequencies;
};
@@ -425,2 +426,3 @@ ODevice::ODevice ( )
d-> m_buttons = 0;
+ d-> m_cpu_frequencies = new QStrList;
}
@@ -775,2 +777,42 @@ int ODevice::lightSensorResolution ( ) const
/**
+ * @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
@@ -1952,2 +1994,7 @@ void Ramses::init()
+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");
}
@@ -2012,2 +2059,3 @@ bool Ramses::suspend ( )
qDebug("Ramses::suspend");
+ return false;
}
@@ -2050,4 +2098,13 @@ bool Ramses::setDisplayBrightness(int bright)
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) {
@@ -2058,4 +2115,2 @@ bool Ramses::setDisplayBrightness(int bright)
::close(fd);
- } else {
- qWarning("no write");
}
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 0974e8d..7f6f856 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -25,2 +25,3 @@
#include <qnamespace.h>
+#include <qstrlist.h>
@@ -154,3 +155,2 @@ public:
-
static ODevice *inst ( );
@@ -200,2 +200,6 @@ public:
+ QStrList &cpuFrequencies() const;
+ bool setCpuFrequency(uint index);
+ uint cpuFrequency() const;
+
/**