author | eilers <eilers> | 2003-08-08 15:09:29 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-08 15:09:29 (UTC) |
commit | b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16 (patch) (unidiff) | |
tree | b0f96db67cfb1b9d2476530ecec9a2ba6eacbab1 /libopie/odevice.cpp | |
parent | 14d394e6c107b037a09a31a92605034fe50f7813 (diff) | |
download | opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.zip opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.gz opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.bz2 |
Merging all changes from BRANCH_1_0.
-rw-r--r-- | libopie/odevice.cpp | 111 |
1 files changed, 63 insertions, 48 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 62dc9d4..17ae389 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -467,16 +467,19 @@ void ODevice::initButtons ( ) | |||
467 | reloadButtonMapping ( ); | 467 | reloadButtonMapping ( ); |
468 | 468 | ||
469 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 469 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
470 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 470 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
471 | } | 471 | } |
472 | 472 | ||
473 | ODevice::~ODevice ( ) | 473 | ODevice::~ODevice ( ) |
474 | { | 474 | { |
475 | // we leak m_devicebuttons and m_cpu_frequency | ||
476 | // but it's a singleton and it is not so importantant | ||
477 | // -zecke | ||
475 | delete d; | 478 | delete d; |
476 | } | 479 | } |
477 | 480 | ||
478 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 481 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
479 | { | 482 | { |
480 | return false; | 483 | return false; |
481 | } | 484 | } |
482 | 485 | ||
@@ -780,17 +783,17 @@ int ODevice::lightSensorResolution ( ) const | |||
780 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 783 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
781 | { | 784 | { |
782 | return *d->m_cpu_frequencies; | 785 | return *d->m_cpu_frequencies; |
783 | } | 786 | } |
784 | 787 | ||
785 | 788 | ||
786 | /** | 789 | /** |
787 | * Set desired CPU frequency | 790 | * Set desired CPU frequency |
788 | * | 791 | * |
789 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 792 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
790 | */ | 793 | */ |
791 | bool ODevice::setCurrentCpuFrequency(uint index) | 794 | bool ODevice::setCurrentCpuFrequency(uint index) |
792 | { | 795 | { |
793 | if (index >= d->m_cpu_frequencies->count()) | 796 | if (index >= d->m_cpu_frequencies->count()) |
794 | return false; | 797 | return false; |
795 | 798 | ||
796 | char *freq = d->m_cpu_frequencies->at(index); | 799 | char *freq = d->m_cpu_frequencies->at(index); |
@@ -915,21 +918,19 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | |||
915 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 918 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 919 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 920 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
918 | 921 | ||
919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 922 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
920 | 923 | ||
921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 924 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
922 | } | 925 | } |
923 | void ODevice::virtual_hook( int id, void* data ) { | 926 | void ODevice::virtual_hook(int, void* ){ |
924 | Q_UNUSED(id); | ||
925 | Q_UNUSED(data); | ||
926 | } | ||
927 | 927 | ||
928 | } | ||
928 | 929 | ||
929 | 930 | ||
930 | /************************************************** | 931 | /************************************************** |
931 | * | 932 | * |
932 | * iPAQ | 933 | * iPAQ |
933 | * | 934 | * |
934 | **************************************************/ | 935 | **************************************************/ |
935 | 936 | ||
@@ -1643,17 +1644,16 @@ bool Zaurus::setDisplayBrightness ( int bright ) | |||
1643 | } | 1644 | } |
1644 | 1645 | ||
1645 | 1646 | ||
1646 | int Zaurus::displayBrightnessResolution ( ) const | 1647 | int Zaurus::displayBrightnessResolution ( ) const |
1647 | { | 1648 | { |
1648 | return 5; | 1649 | return 5; |
1649 | } | 1650 | } |
1650 | 1651 | ||
1651 | |||
1652 | /************************************************** | 1652 | /************************************************** |
1653 | * | 1653 | * |
1654 | * SIMpad | 1654 | * SIMpad |
1655 | * | 1655 | * |
1656 | **************************************************/ | 1656 | **************************************************/ |
1657 | 1657 | ||
1658 | void SIMpad::init ( ) | 1658 | void SIMpad::init ( ) |
1659 | { | 1659 | { |
@@ -1884,17 +1884,17 @@ bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | |||
1884 | return false; | 1884 | return false; |
1885 | 1885 | ||
1886 | bool res = false; | 1886 | bool res = false; |
1887 | 1887 | ||
1888 | struct timeval tvs, tvn; | 1888 | struct timeval tvs, tvn; |
1889 | ::gettimeofday ( &tvs, 0 ); | 1889 | ::gettimeofday ( &tvs, 0 ); |
1890 | 1890 | ||
1891 | ::sync ( ); // flush fs caches | 1891 | ::sync ( ); // flush fs caches |
1892 | res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) | 1892 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
1893 | 1893 | ||
1894 | return res; | 1894 | return res; |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | 1897 | ||
1898 | bool SIMpad::setSoftSuspend ( bool soft ) | 1898 | bool SIMpad::setSoftSuspend ( bool soft ) |
1899 | { | 1899 | { |
1900 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 1900 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
@@ -1906,33 +1906,31 @@ bool SIMpad::setDisplayStatus ( bool on ) | |||
1906 | { | 1906 | { |
1907 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 1907 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
1908 | 1908 | ||
1909 | bool res = false; | 1909 | bool res = false; |
1910 | int fd; | 1910 | int fd; |
1911 | 1911 | ||
1912 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 1912 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
1913 | 1913 | ||
1914 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 1914 | res = ( ::system( (const char*) cmdline ) == 0 ); |
1915 | res = ( ::system( (const char*) cmdline ) == 0 ); | 1915 | |
1916 | ::close ( fd ); | ||
1917 | } | ||
1918 | return res; | 1916 | return res; |
1919 | } | 1917 | } |
1920 | 1918 | ||
1921 | 1919 | ||
1922 | bool SIMpad::setDisplayBrightness ( int bright ) | 1920 | bool SIMpad::setDisplayBrightness ( int bright ) |
1923 | { | 1921 | { |
1924 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 1922 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
1925 | bool res = false; | 1923 | bool res = false; |
1926 | int fd; | 1924 | int fd; |
1927 | 1925 | ||
1928 | if ( bright > 255 ) | 1926 | if ( bright > 255 ) |
1929 | bright = 255; | 1927 | bright = 255; |
1930 | if ( bright < 0 ) | 1928 | if ( bright < 1 ) |
1931 | bright = 0; | 1929 | bright = 0; |
1932 | 1930 | ||
1933 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 1931 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
1934 | int value = 255 - bright; | 1932 | int value = 255 - bright; |
1935 | const int mask = SIMPAD_BACKLIGHT_MASK; | 1933 | const int mask = SIMPAD_BACKLIGHT_MASK; |
1936 | value = value << 8; | 1934 | value = value << 8; |
1937 | value += mask; | 1935 | value += mask; |
1938 | char writeCommand[100]; | 1936 | char writeCommand[100]; |
@@ -1941,26 +1939,17 @@ bool SIMpad::setDisplayBrightness ( int bright ) | |||
1941 | ::close ( fd ); | 1939 | ::close ( fd ); |
1942 | } | 1940 | } |
1943 | return res; | 1941 | return res; |
1944 | } | 1942 | } |
1945 | 1943 | ||
1946 | 1944 | ||
1947 | int SIMpad::displayBrightnessResolution ( ) const | 1945 | int SIMpad::displayBrightnessResolution ( ) const |
1948 | { | 1946 | { |
1949 | switch ( model ( )) { | 1947 | return 255; // All SIMpad models share the same display |
1950 | case Model_SIMpad_CL4: | ||
1951 | case Model_SIMpad_SL4: | ||
1952 | case Model_SIMpad_SLC: | ||
1953 | case Model_SIMpad_TSinus: | ||
1954 | return 255; //TODO find out if this is save | ||
1955 | |||
1956 | default: | ||
1957 | return 2; | ||
1958 | } | ||
1959 | } | 1948 | } |
1960 | 1949 | ||
1961 | /************************************************** | 1950 | /************************************************** |
1962 | * | 1951 | * |
1963 | * Ramses | 1952 | * Ramses |
1964 | * | 1953 | * |
1965 | **************************************************/ | 1954 | **************************************************/ |
1966 | 1955 | ||
@@ -1969,19 +1958,18 @@ void Ramses::init() | |||
1969 | d->m_vendorstr = "M und N"; | 1958 | d->m_vendorstr = "M und N"; |
1970 | d->m_vendor = Vendor_MundN; | 1959 | d->m_vendor = Vendor_MundN; |
1971 | 1960 | ||
1972 | QFile f("/proc/sys/board/ramses"); | 1961 | QFile f("/proc/sys/board/ramses"); |
1973 | 1962 | ||
1974 | d->m_modelstr = "Ramses"; | 1963 | d->m_modelstr = "Ramses"; |
1975 | d->m_model = Model_Ramses_MNCI; | 1964 | d->m_model = Model_Ramses_MNCI; |
1976 | 1965 | ||
1977 | d->m_rotation = Rot180; | 1966 | d->m_rotation = Rot0; |
1978 | d->m_direction = CW; | 1967 | d->m_holdtime = 1000; |
1979 | d->m_holdtime = 1000; | ||
1980 | 1968 | ||
1981 | f.setName("/etc/oz_version"); | 1969 | f.setName("/etc/oz_version"); |
1982 | 1970 | ||
1983 | if (f.open(IO_ReadOnly)) { | 1971 | if (f.open(IO_ReadOnly)) { |
1984 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1972 | d->m_systemstr = "OpenEmbedded/Ramses"; |
1985 | d->m_system = System_OpenZaurus; | 1973 | d->m_system = System_OpenZaurus; |
1986 | 1974 | ||
1987 | QTextStream ts(&f); | 1975 | QTextStream ts(&f); |
@@ -2029,59 +2017,84 @@ void Ramses::timerEvent(QTimerEvent *) | |||
2029 | m_power_timer = 0; | 2017 | m_power_timer = 0; |
2030 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2018 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
2031 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2019 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
2032 | } | 2020 | } |
2033 | 2021 | ||
2034 | 2022 | ||
2035 | bool Ramses::setSoftSuspend(bool soft) | 2023 | bool Ramses::setSoftSuspend(bool soft) |
2036 | { | 2024 | { |
2037 | Q_UNUSED(soft); | 2025 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
2038 | return true; | 2026 | #if 0 |
2039 | } | ||
2040 | |||
2041 | bool Ramses::suspend() | ||
2042 | { | ||
2043 | //qDebug("Ramses::suspend()"); | ||
2044 | if ( !isQWS() ) // only qwsserver is allowed to suspend | ||
2045 | return false; | ||
2046 | |||
2047 | bool res = false; | 2027 | bool res = false; |
2048 | int fd; | 2028 | int fd; |
2049 | 2029 | ||
2050 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { | 2030 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
2051 | res = ( ::write ( fd, "1", 1 ) != -1 ); | 2031 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
2032 | |||
2033 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | ||
2034 | |||
2035 | if (sources >= 0) { | ||
2036 | if (soft) | ||
2037 | sources &= ~APM_EVT_POWER_BUTTON; | ||
2038 | else | ||
2039 | sources |= APM_EVT_POWER_BUTTON; | ||
2040 | |||
2041 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | ||
2042 | res = true; | ||
2043 | else | ||
2044 | perror("APM_IOCGEVTSRC"); | ||
2045 | } | ||
2046 | else | ||
2047 | perror("APM_IOCGEVTSRC"); | ||
2048 | |||
2052 | ::close(fd); | 2049 | ::close(fd); |
2053 | } | 2050 | } |
2054 | return res; | 2051 | else |
2052 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | ||
2053 | |||
2054 | return res; | ||
2055 | #else | ||
2056 | return true; | ||
2057 | #endif | ||
2058 | } | ||
2059 | |||
2060 | bool Ramses::suspend ( ) | ||
2061 | { | ||
2062 | qDebug("Ramses::suspend"); | ||
2063 | return false; | ||
2055 | } | 2064 | } |
2056 | 2065 | ||
2057 | /** | 2066 | /** |
2058 | * This sets the display on or off | 2067 | * This sets the display on or off |
2059 | */ | 2068 | */ |
2060 | bool Ramses::setDisplayStatus(bool on) | 2069 | bool Ramses::setDisplayStatus(bool on) |
2061 | { | 2070 | { |
2062 | //qDebug("Ramses::setDisplayStatus(%d)", on); | 2071 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2072 | #if 0 | ||
2063 | bool res = false; | 2073 | bool res = false; |
2064 | int fd; | 2074 | int fd; |
2065 | 2075 | ||
2066 | if ((fd = ::open ("/dev/fb/1", O_RDWR)) >= 0) { | 2076 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2067 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2077 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2068 | ::close(fd); | 2078 | ::close(fd); |
2069 | } | 2079 | } |
2070 | return res; | 2080 | return res; |
2081 | #else | ||
2082 | return true; | ||
2083 | #endif | ||
2071 | } | 2084 | } |
2072 | 2085 | ||
2073 | 2086 | ||
2074 | /* | 2087 | /* |
2075 | * We get something between 0..255 into us | 2088 | * We get something between 0..255 into us |
2076 | */ | 2089 | */ |
2077 | bool Ramses::setDisplayBrightness(int bright) | 2090 | bool Ramses::setDisplayBrightness(int bright) |
2078 | { | 2091 | { |
2079 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2092 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2080 | bool res = false; | 2093 | bool res = false; |
2081 | int fd; | 2094 | int fd; |
2082 | 2095 | ||
2083 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2096 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2084 | 2097 | ||
2085 | if (bright > 255 ) | 2098 | if (bright > 255 ) |
2086 | bright = 255; | 2099 | bright = 255; |
2087 | if (bright < 0) | 2100 | if (bright < 0) |
@@ -2091,53 +2104,55 @@ bool Ramses::setDisplayBrightness(int bright) | |||
2091 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 2104 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
2092 | char writeCommand[10]; | 2105 | char writeCommand[10]; |
2093 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 2106 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
2094 | res = (::write(fd, writeCommand, count) != -1); | 2107 | res = (::write(fd, writeCommand, count) != -1); |
2095 | ::close(fd); | 2108 | ::close(fd); |
2096 | } | 2109 | } |
2097 | 2110 | ||
2098 | // scale backlight brightness to hardware | 2111 | // scale backlight brightness to hardware |
2099 | if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { | 2112 | bright = 500-(bright * 500 / 255); |
2100 | //qDebug(" %d -> pwm1", bright); | 2113 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2114 | qDebug(" %d -> pwm1", bright); | ||
2101 | char writeCommand[100]; | 2115 | char writeCommand[100]; |
2102 | const int count = sprintf(writeCommand, "%d\n", bright); | 2116 | const int count = sprintf(writeCommand, "%d\n", bright); |
2103 | res = (::write(fd, writeCommand, count) != -1); | 2117 | res = (::write(fd, writeCommand, count) != -1); |
2104 | ::close(fd); | 2118 | ::close(fd); |
2105 | } | 2119 | } |
2106 | return res; | 2120 | return res; |
2107 | } | 2121 | } |
2108 | 2122 | ||
2109 | 2123 | ||
2110 | int Ramses::displayBrightnessResolution() const | 2124 | int Ramses::displayBrightnessResolution() const |
2111 | { | 2125 | { |
2112 | return 256; | 2126 | return 32; |
2113 | } | 2127 | } |
2114 | 2128 | ||
2115 | bool Ramses::setDisplayContrast(int contr) | 2129 | bool Ramses::setDisplayContrast(int contr) |
2116 | { | 2130 | { |
2117 | //qDebug("Ramses::setDisplayContrast(%d)", contr); | 2131 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2118 | bool res = false; | 2132 | bool res = false; |
2119 | int fd; | 2133 | int fd; |
2120 | 2134 | ||
2121 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2135 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2122 | 2136 | ||
2123 | if (contr > 255 ) | 2137 | if (contr > 255 ) |
2124 | contr = 255; | 2138 | contr = 255; |
2125 | if (contr < 0) | 2139 | if (contr < 0) |
2126 | contr = 0; | 2140 | contr = 0; |
2141 | contr = 90 - (contr * 20 / 255); | ||
2127 | 2142 | ||
2128 | if ((fd = ::open("/proc/sys/board/lcd_contrast", O_WRONLY)) >= 0) { | 2143 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2129 | //qDebug(" %d -> pwm0", contr); | 2144 | qDebug(" %d -> pwm0", contr); |
2130 | char writeCommand[100]; | 2145 | char writeCommand[100]; |
2131 | const int count = sprintf(writeCommand, "%d\n", contr); | 2146 | const int count = sprintf(writeCommand, "%d\n", contr); |
2132 | res = (::write(fd, writeCommand, count) != -1); | 2147 | res = (::write(fd, writeCommand, count) != -1); |
2133 | res = true; | 2148 | res = true; |
2134 | ::close(fd); | 2149 | ::close(fd); |
2135 | } | 2150 | } |
2136 | return res; | 2151 | return res; |
2137 | } | 2152 | } |
2138 | 2153 | ||
2139 | 2154 | ||
2140 | int Ramses::displayContrastResolution() const | 2155 | int Ramses::displayContrastResolution() const |
2141 | { | 2156 | { |
2142 | return 256; | 2157 | return 20; |
2143 | } | 2158 | } |