-rw-r--r-- | libopie/odevice.cpp | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 4b5a54e..4c33a0e 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -750,99 +750,95 @@ bool ODevice::setLedState ( OLed which, OLedState st ) | |||
750 | return false; | 750 | return false; |
751 | } | 751 | } |
752 | 752 | ||
753 | /** | 753 | /** |
754 | * @return if the device has a light sensor | 754 | * @return if the device has a light sensor |
755 | */ | 755 | */ |
756 | bool ODevice::hasLightSensor ( ) const | 756 | bool ODevice::hasLightSensor ( ) const |
757 | { | 757 | { |
758 | return false; | 758 | return false; |
759 | } | 759 | } |
760 | 760 | ||
761 | /** | 761 | /** |
762 | * @return a value from the light senso | 762 | * @return a value from the light senso |
763 | */ | 763 | */ |
764 | int ODevice::readLightSensor ( ) | 764 | int ODevice::readLightSensor ( ) |
765 | { | 765 | { |
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; |
833 | } | 829 | } |
834 | 830 | ||
835 | /** | 831 | /** |
836 | * This method return a ODeviceButton for a key code | 832 | * This method return a ODeviceButton for a key code |
837 | * or 0 if no special hardware button is available for the device | 833 | * or 0 if no special hardware button is available for the device |
838 | * | 834 | * |
839 | * @return The devicebutton or 0l | 835 | * @return The devicebutton or 0l |
840 | * @see ODeviceButton | 836 | * @see ODeviceButton |
841 | */ | 837 | */ |
842 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 838 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
843 | { | 839 | { |
844 | initButtons ( ); | 840 | initButtons ( ); |
845 | 841 | ||
846 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 842 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
847 | if ( (*it). keycode ( ) == code ) | 843 | if ( (*it). keycode ( ) == code ) |
848 | return &(*it); | 844 | return &(*it); |
@@ -1963,69 +1959,84 @@ int SIMpad::displayBrightnessResolution ( ) const | |||
1963 | * | 1959 | * |
1964 | * Ramses | 1960 | * Ramses |
1965 | * | 1961 | * |
1966 | **************************************************/ | 1962 | **************************************************/ |
1967 | 1963 | ||
1968 | void Ramses::init() | 1964 | void Ramses::init() |
1969 | { | 1965 | { |
1970 | d->m_vendorstr = "M und N"; | 1966 | d->m_vendorstr = "M und N"; |
1971 | d->m_vendor = Vendor_MundN; | 1967 | d->m_vendor = Vendor_MundN; |
1972 | 1968 | ||
1973 | QFile f("/proc/sys/board/ramses"); | 1969 | QFile f("/proc/sys/board/ramses"); |
1974 | 1970 | ||
1975 | d->m_modelstr = "Ramses"; | 1971 | d->m_modelstr = "Ramses"; |
1976 | d->m_model = Model_Ramses_MNCI; | 1972 | d->m_model = Model_Ramses_MNCI; |
1977 | 1973 | ||
1978 | d->m_rotation = Rot0; | 1974 | d->m_rotation = Rot0; |
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); |
2016 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2027 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
2017 | } | 2028 | } |
2018 | 2029 | ||
2019 | 2030 | ||
2020 | bool Ramses::setSoftSuspend(bool soft) | 2031 | bool Ramses::setSoftSuspend(bool soft) |
2021 | { | 2032 | { |
2022 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 2033 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
2023 | #if 0 | 2034 | #if 0 |
2024 | bool res = false; | 2035 | bool res = false; |
2025 | int fd; | 2036 | int fd; |
2026 | 2037 | ||
2027 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 2038 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
2028 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 2039 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
2029 | 2040 | ||
2030 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 2041 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
2031 | 2042 | ||
@@ -2115,43 +2126,41 @@ bool Ramses::setDisplayBrightness(int bright) | |||
2115 | ::close(fd); | 2126 | ::close(fd); |
2116 | } | 2127 | } |
2117 | return res; | 2128 | return res; |
2118 | } | 2129 | } |
2119 | 2130 | ||
2120 | 2131 | ||
2121 | int Ramses::displayBrightnessResolution() const | 2132 | int Ramses::displayBrightnessResolution() const |
2122 | { | 2133 | { |
2123 | return 32; | 2134 | return 32; |
2124 | } | 2135 | } |
2125 | 2136 | ||
2126 | bool Ramses::setDisplayContrast(int contr) | 2137 | bool Ramses::setDisplayContrast(int contr) |
2127 | { | 2138 | { |
2128 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2139 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2129 | bool res = false; | 2140 | bool res = false; |
2130 | int fd; | 2141 | int fd; |
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 | } |