-rw-r--r-- | libopie/odevice.cpp | 61 | ||||
-rw-r--r-- | libopie/odevice.h | 10 |
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 | |||
@@ -72,6 +72,7 @@ public: | |||
72 | 72 | ||
73 | QValueList <ODeviceButton> *m_buttons; | 73 | QValueList <ODeviceButton> *m_buttons; |
74 | uint m_holdtime; | 74 | uint m_holdtime; |
75 | QStrList *m_cpu_frequencies; | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | 78 | ||
@@ -423,6 +424,7 @@ ODevice::ODevice ( ) | |||
423 | 424 | ||
424 | d-> m_holdtime = 1000; // 1000ms | 425 | d-> m_holdtime = 1000; // 1000ms |
425 | d-> m_buttons = 0; | 426 | d-> m_buttons = 0; |
427 | d-> m_cpu_frequencies = new QStrList; | ||
426 | } | 428 | } |
427 | 429 | ||
428 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 430 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
@@ -773,6 +775,46 @@ int ODevice::lightSensorResolution ( ) const | |||
773 | } | 775 | } |
774 | 776 | ||
775 | /** | 777 | /** |
778 | * @return a list with valid CPU frequency | ||
779 | */ | ||
780 | QStrList &ODevice::cpuFrequencies ( ) const | ||
781 | { | ||
782 | qWarning("ODevice::cpuFrequencies: m_cpu_frequencies is %d", (int) d->m_cpu_frequencies); | ||
783 | return *d->m_cpu_frequencies; | ||
784 | } | ||
785 | |||
786 | |||
787 | /** | ||
788 | * Set desired cpu frequency | ||
789 | * | ||
790 | * @param index index into d->m_cpu_frequencies of the frequency to be set | ||
791 | */ | ||
792 | bool ODevice::setCpuFrequency(uint index) | ||
793 | { | ||
794 | if (index >= d->m_cpu_frequencies->count()) | ||
795 | return false; | ||
796 | |||
797 | char *freq = d->m_cpu_frequencies->at(index); | ||
798 | qWarning("set freq to %s", freq); | ||
799 | |||
800 | //TODO: do the change in /proc/sys/cpu/0/speed | ||
801 | |||
802 | return false; | ||
803 | } | ||
804 | |||
805 | /** | ||
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 | } | ||
814 | |||
815 | |||
816 | |||
817 | /** | ||
776 | * @return a list of hardware buttons | 818 | * @return a list of hardware buttons |
777 | */ | 819 | */ |
778 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 820 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
@@ -1950,6 +1992,11 @@ void Ramses::init() | |||
1950 | 1992 | ||
1951 | m_power_timer = 0; | 1993 | m_power_timer = 0; |
1952 | 1994 | ||
1995 | qWarning("adding freq"); | ||
1996 | d->m_cpu_frequencies->append("100"); | ||
1997 | d->m_cpu_frequencies->append("200"); | ||
1998 | d->m_cpu_frequencies->append("300"); | ||
1999 | d->m_cpu_frequencies->append("400"); | ||
1953 | } | 2000 | } |
1954 | 2001 | ||
1955 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 2002 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
@@ -2010,6 +2057,7 @@ bool Ramses::setSoftSuspend(bool soft) | |||
2010 | bool Ramses::suspend ( ) | 2057 | bool Ramses::suspend ( ) |
2011 | { | 2058 | { |
2012 | qDebug("Ramses::suspend"); | 2059 | qDebug("Ramses::suspend"); |
2060 | return false; | ||
2013 | } | 2061 | } |
2014 | 2062 | ||
2015 | /** | 2063 | /** |
@@ -2048,16 +2096,23 @@ bool Ramses::setDisplayBrightness(int bright) | |||
2048 | bright = 255; | 2096 | bright = 255; |
2049 | if (bright < 0) | 2097 | if (bright < 0) |
2050 | bright = 0; | 2098 | bright = 0; |
2051 | bright = 500-(bright * 500 / 255); | ||
2052 | 2099 | ||
2100 | // Turn backlight completely off | ||
2101 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | ||
2102 | char writeCommand[10]; | ||
2103 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | ||
2104 | res = (::write(fd, writeCommand, count) != -1); | ||
2105 | ::close(fd); | ||
2106 | } | ||
2107 | |||
2108 | // scale backlight brightness to hardware | ||
2109 | bright = 500-(bright * 500 / 255); | ||
2053 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2110 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2054 | qDebug(" %d -> pwm1", bright); | 2111 | qDebug(" %d -> pwm1", bright); |
2055 | char writeCommand[100]; | 2112 | char writeCommand[100]; |
2056 | const int count = sprintf(writeCommand, "%d\n", bright); | 2113 | const int count = sprintf(writeCommand, "%d\n", bright); |
2057 | res = (::write(fd, writeCommand, count) != -1); | 2114 | res = (::write(fd, writeCommand, count) != -1); |
2058 | ::close(fd); | 2115 | ::close(fd); |
2059 | } else { | ||
2060 | qWarning("no write"); | ||
2061 | } | 2116 | } |
2062 | return res; | 2117 | return res; |
2063 | } | 2118 | } |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 0974e8d..7f6f856 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qnamespace.h> | 25 | #include <qnamespace.h> |
26 | #include <qstrlist.h> | ||
26 | 27 | ||
27 | #include <opie/odevicebutton.h> | 28 | #include <opie/odevicebutton.h> |
28 | 29 | ||
@@ -149,13 +150,12 @@ protected: | |||
149 | ODeviceData *d; | 150 | ODeviceData *d; |
150 | 151 | ||
151 | public: | 152 | public: |
152 | // sandman do we want to allow destructions? -zecke? | 153 | // sandman do we want to allow destructions? -zecke? |
153 | virtual ~ODevice ( ); | 154 | virtual ~ODevice ( ); |
154 | 155 | ||
155 | |||
156 | static ODevice *inst ( ); | 156 | static ODevice *inst ( ); |
157 | 157 | ||
158 | // information | 158 | // information |
159 | 159 | ||
160 | QString modelString ( ) const; | 160 | QString modelString ( ) const; |
161 | OModel model ( ) const; | 161 | OModel model ( ) const; |
@@ -198,6 +198,10 @@ public: | |||
198 | virtual int readLightSensor ( ); | 198 | virtual int readLightSensor ( ); |
199 | virtual int lightSensorResolution ( ) const; | 199 | virtual int lightSensorResolution ( ) const; |
200 | 200 | ||
201 | QStrList &cpuFrequencies() const; | ||
202 | bool setCpuFrequency(uint index); | ||
203 | uint cpuFrequency() const; | ||
204 | |||
201 | /** | 205 | /** |
202 | * Returns the available buttons on this device. The number and location | 206 | * Returns the available buttons on this device. The number and location |
203 | * of buttons will vary depending on the device. Button numbers will be assigned | 207 | * of buttons will vary depending on the device. Button numbers will be assigned |