-rw-r--r-- | libopie/odevice.cpp | 49 | ||||
-rw-r--r-- | libopie/odevice.h | 2 |
2 files changed, 30 insertions, 21 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 4b5a54e..4c33a0e 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -766,67 +766,63 @@ int ODevice::readLightSensor ( ) | |||
766 | return -1; | 766 | return -1; |
767 | } | 767 | } |
768 | 768 | ||
769 | /** | 769 | /** |
770 | * @return the light sensor resolution whatever that is ;) | 770 | * @return the light sensor resolution whatever that is ;) |
771 | */ | 771 | */ |
772 | int ODevice::lightSensorResolution ( ) const | 772 | int ODevice::lightSensorResolution ( ) const |
773 | { | 773 | { |
774 | return 0; | 774 | return 0; |
775 | } | 775 | } |
776 | 776 | ||
777 | /** | 777 | /** |
778 | * @return a list with valid CPU frequency | 778 | * @return a list with valid CPU frequency |
779 | */ | 779 | */ |
780 | QStrList &ODevice::cpuFrequencies ( ) const | 780 | QStrList &ODevice::cpuFrequencies ( ) const |
781 | { | 781 | { |
782 | qWarning("ODevice::cpuFrequencies: m_cpu_frequencies is %d", (int) d->m_cpu_frequencies); | ||
783 | return *d->m_cpu_frequencies; | 782 | return *d->m_cpu_frequencies; |
784 | } | 783 | } |
785 | 784 | ||
786 | 785 | ||
787 | /** | 786 | /** |
788 | * Set desired cpu frequency | 787 | * Set desired cpu frequency |
789 | * | 788 | * |
790 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 789 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
791 | */ | 790 | */ |
792 | bool ODevice::setCpuFrequency(uint index) | 791 | bool ODevice::setCpuFrequency(uint index) |
793 | { | 792 | { |
794 | if (index >= d->m_cpu_frequencies->count()) | 793 | if (index >= d->m_cpu_frequencies->count()) |
795 | return false; | 794 | return false; |
796 | 795 | ||
797 | char *freq = d->m_cpu_frequencies->at(index); | 796 | char *freq = d->m_cpu_frequencies->at(index); |
798 | qWarning("set freq to %s", freq); | 797 | qWarning("set freq to %s", freq); |
799 | 798 | ||
800 | //TODO: do the change in /proc/sys/cpu/0/speed | 799 | int fd; |
801 | |||
802 | return false; | ||
803 | } | ||
804 | 800 | ||
805 | /** | 801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
806 | * Returns current frequency index out of d->m_cpu_frequencies | 802 | char writeCommand[50]; |
807 | */ | 803 | const int count = sprintf(writeCommand, "%s\n", freq); |
808 | uint ODevice::cpuFrequency() const | 804 | int res = (::write(fd, writeCommand, count) != -1); |
809 | { | 805 | ::close(fd); |
810 | // TODO: get freq from /proc/sys/cpu/0/speed and return index | 806 | return res; |
807 | } | ||
811 | 808 | ||
812 | return 0; | 809 | return false; |
813 | } | 810 | } |
814 | 811 | ||
815 | 812 | ||
816 | |||
817 | /** | 813 | /** |
818 | * @return a list of hardware buttons | 814 | * @return a list of hardware buttons |
819 | */ | 815 | */ |
820 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 816 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
821 | { | 817 | { |
822 | initButtons ( ); | 818 | initButtons ( ); |
823 | 819 | ||
824 | return *d-> m_buttons; | 820 | return *d-> m_buttons; |
825 | } | 821 | } |
826 | 822 | ||
827 | /** | 823 | /** |
828 | * @return The amount of time that would count as a hold | 824 | * @return The amount of time that would count as a hold |
829 | */ | 825 | */ |
830 | uint ODevice::buttonHoldTime ( ) const | 826 | uint ODevice::buttonHoldTime ( ) const |
831 | { | 827 | { |
832 | return d-> m_holdtime; | 828 | return d-> m_holdtime; |
@@ -1979,37 +1975,52 @@ void Ramses::init() | |||
1979 | d->m_holdtime = 1000; | 1975 | d->m_holdtime = 1000; |
1980 | 1976 | ||
1981 | f.setName("/etc/oz_version"); | 1977 | f.setName("/etc/oz_version"); |
1982 | 1978 | ||
1983 | if (f.open(IO_ReadOnly)) { | 1979 | if (f.open(IO_ReadOnly)) { |
1984 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1980 | d->m_systemstr = "OpenEmbedded/Ramses"; |
1985 | d->m_system = System_OpenZaurus; | 1981 | d->m_system = System_OpenZaurus; |
1986 | 1982 | ||
1987 | QTextStream ts(&f); | 1983 | QTextStream ts(&f); |
1988 | ts.setDevice(&f); | 1984 | ts.setDevice(&f); |
1989 | d->m_sysverstr = ts.readLine(); | 1985 | d->m_sysverstr = ts.readLine(); |
1990 | f.close(); | 1986 | f.close(); |
1991 | } | 1987 | } |
1992 | 1988 | ||
1993 | m_power_timer = 0; | 1989 | m_power_timer = 0; |
1994 | 1990 | ||
1995 | qWarning("adding freq"); | 1991 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
1996 | d->m_cpu_frequencies->append("100"); | 1992 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
1997 | d->m_cpu_frequencies->append("200"); | 1993 | #define OC(x...) x |
1998 | d->m_cpu_frequencies->append("300"); | 1994 | #else |
1999 | d->m_cpu_frequencies->append("400"); | 1995 | #define OC(x...) |
1996 | #endif | ||
1997 | |||
1998 | |||
1999 | // This table is true for a Intel XScale PXA 255 | ||
2000 | |||
2001 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | ||
2002 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | ||
2003 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | ||
2004 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | ||
2005 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | ||
2006 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | ||
2007 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | ||
2008 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | ||
2009 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | ||
2010 | |||
2000 | } | 2011 | } |
2001 | 2012 | ||
2002 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 2013 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
2003 | { | 2014 | { |
2004 | Q_UNUSED( keycode ); | 2015 | Q_UNUSED( keycode ); |
2005 | Q_UNUSED( modifiers ); | 2016 | Q_UNUSED( modifiers ); |
2006 | Q_UNUSED( isPress ); | 2017 | Q_UNUSED( isPress ); |
2007 | Q_UNUSED( autoRepeat ); | 2018 | Q_UNUSED( autoRepeat ); |
2008 | return false; | 2019 | return false; |
2009 | } | 2020 | } |
2010 | 2021 | ||
2011 | void Ramses::timerEvent(QTimerEvent *) | 2022 | void Ramses::timerEvent(QTimerEvent *) |
2012 | { | 2023 | { |
2013 | killTimer(m_power_timer); | 2024 | killTimer(m_power_timer); |
2014 | m_power_timer = 0; | 2025 | m_power_timer = 0; |
2015 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2026 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
@@ -2131,27 +2142,25 @@ bool Ramses::setDisplayContrast(int contr) | |||
2131 | 2142 | ||
2132 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2143 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2133 | 2144 | ||
2134 | if (contr > 255 ) | 2145 | if (contr > 255 ) |
2135 | contr = 255; | 2146 | contr = 255; |
2136 | if (contr < 0) | 2147 | if (contr < 0) |
2137 | contr = 0; | 2148 | contr = 0; |
2138 | contr = 90 - (contr * 20 / 255); | 2149 | contr = 90 - (contr * 20 / 255); |
2139 | 2150 | ||
2140 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2151 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2141 | qDebug(" %d -> pwm0", contr); | 2152 | qDebug(" %d -> pwm0", contr); |
2142 | char writeCommand[100]; | 2153 | char writeCommand[100]; |
2143 | const int count = sprintf(writeCommand, "%d\n", contr); | 2154 | const int count = sprintf(writeCommand, "%d\n", contr); |
2144 | res = (::write(fd, writeCommand, count) != -1); | 2155 | res = (::write(fd, writeCommand, count) != -1); |
2145 | res = true; | 2156 | res = true; |
2146 | ::close(fd); | 2157 | ::close(fd); |
2147 | } else { | ||
2148 | qWarning("no write"); | ||
2149 | } | 2158 | } |
2150 | return res; | 2159 | return res; |
2151 | } | 2160 | } |
2152 | 2161 | ||
2153 | 2162 | ||
2154 | int Ramses::displayContrastResolution() const | 2163 | int Ramses::displayContrastResolution() const |
2155 | { | 2164 | { |
2156 | return 20; | 2165 | return 20; |
2157 | } | 2166 | } |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 7f6f856..18ff5f1 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -187,33 +187,33 @@ public: | |||
187 | //FIXME playAlarmSound and al might be better -zecke | 187 | //FIXME playAlarmSound and al might be better -zecke |
188 | virtual void alarmSound ( ); | 188 | virtual void alarmSound ( ); |
189 | virtual void keySound ( ); | 189 | virtual void keySound ( ); |
190 | virtual void touchSound ( ); | 190 | virtual void touchSound ( ); |
191 | 191 | ||
192 | virtual QValueList <OLed> ledList ( ) const; | 192 | virtual QValueList <OLed> ledList ( ) const; |
193 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 193 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
194 | virtual OLedState ledState ( OLed led ) const; | 194 | virtual OLedState ledState ( OLed led ) const; |
195 | virtual bool setLedState ( OLed led, OLedState st ); | 195 | virtual bool setLedState ( OLed led, OLedState st ); |
196 | 196 | ||
197 | virtual bool hasLightSensor ( ) const; | 197 | virtual bool hasLightSensor ( ) const; |
198 | virtual int readLightSensor ( ); | 198 | virtual int readLightSensor ( ); |
199 | virtual int lightSensorResolution ( ) const; | 199 | virtual int lightSensorResolution ( ) const; |
200 | 200 | ||
201 | QStrList &cpuFrequencies() const; | 201 | QStrList &cpuFrequencies() const; |
202 | bool setCpuFrequency(uint index); | 202 | bool setCpuFrequency(uint index); |
203 | uint cpuFrequency() const; | 203 | int cpuFrequency() const; |
204 | 204 | ||
205 | /** | 205 | /** |
206 | * Returns the available buttons on this device. The number and location | 206 | * Returns the available buttons on this device. The number and location |
207 | * 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 |
208 | * by the device manufacturer and will be from most preferred button to least preffered | 208 | * by the device manufacturer and will be from most preferred button to least preffered |
209 | * button. Note that this list only contains "user mappable" buttons. | 209 | * button. Note that this list only contains "user mappable" buttons. |
210 | */ | 210 | */ |
211 | const QValueList<ODeviceButton> &buttons ( ); | 211 | const QValueList<ODeviceButton> &buttons ( ); |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 214 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
215 | * returns 0L | 215 | * returns 0L |
216 | */ | 216 | */ |
217 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 217 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
218 | 218 | ||
219 | /** | 219 | /** |