-rw-r--r-- | libopie/odevice.cpp | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index f808960..4b5a54e 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -67,16 +67,17 @@ public: QString m_sysverstr; Transformation m_rotation; ODirection m_direction; QValueList <ODeviceButton> *m_buttons; uint m_holdtime; + QStrList *m_cpu_frequencies; }; class iPAQ : public ODevice, public QWSServer::KeyboardFilter { protected: virtual void init ( ); virtual void initButtons ( ); @@ -418,16 +419,17 @@ ODevice::ODevice ( ) d-> m_systemstr = "Unknown"; d-> m_system = System_Unknown; d-> m_sysverstr = "0.0"; d-> m_rotation = Rot0; 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 & ) { if ( msg == "deviceButtonMappingChanged()" ) { reloadButtonMapping ( ); } } @@ -768,16 +770,56 @@ 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; +} + +/** + * 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 ( ) { initButtons ( ); return *d-> m_buttons; } @@ -1945,16 +1987,21 @@ void Ramses::init() 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"); } 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 ); @@ -2005,16 +2052,17 @@ bool Ramses::setSoftSuspend(bool soft) #else return true; #endif } bool Ramses::suspend ( ) { qDebug("Ramses::suspend"); + return false; } /** * This sets the display on or off */ bool Ramses::setDisplayStatus(bool on) { qDebug("Ramses::setDisplayStatus(%d)", on); @@ -2043,26 +2091,33 @@ bool Ramses::setDisplayBrightness(int bright) int fd; // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 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; } int Ramses::displayBrightnessResolution() const { return 32; |