summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authoreilers <eilers>2003-08-08 15:09:29 (UTC)
committer eilers <eilers>2003-08-08 15:09:29 (UTC)
commitb87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16 (patch) (unidiff)
treeb0f96db67cfb1b9d2476530ecec9a2ba6eacbab1 /libopie/odevice.cpp
parent14d394e6c107b037a09a31a92605034fe50f7813 (diff)
downloadopie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.zip
opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.gz
opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.bz2
Merging all changes from BRANCH_1_0.
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp111
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
@@ -472,6 +472,9 @@ void ODevice::initButtons ( )
472 472
473ODevice::~ODevice ( ) 473ODevice::~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
@@ -785,7 +788,7 @@ const QStrList &ODevice::allowedCpuFrequencies ( ) const
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 */
791bool ODevice::setCurrentCpuFrequency(uint index) 794bool ODevice::setCurrentCpuFrequency(uint index)
@@ -920,11 +923,9 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
920 923
921 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 924 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
922} 925}
923void ODevice::virtual_hook( int id, void* data ) { 926void ODevice::virtual_hook(int, void* ){
924 Q_UNUSED(id);
925 Q_UNUSED(data);
926}
927 927
928}
928 929
929 930
930/************************************************** 931/**************************************************
@@ -1648,7 +1649,6 @@ int Zaurus::displayBrightnessResolution ( ) const
1648 return 5; 1649 return 5;
1649} 1650}
1650 1651
1651
1652/************************************************** 1652/**************************************************
1653 * 1653 *
1654 * SIMpad 1654 * SIMpad
@@ -1889,7 +1889,7 @@ bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
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}
@@ -1911,10 +1911,8 @@ bool SIMpad::setDisplayStatus ( bool on )
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
@@ -1927,7 +1925,7 @@ bool SIMpad::setDisplayBrightness ( int bright )
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 ) {
@@ -1946,16 +1944,7 @@ bool SIMpad::setDisplayBrightness ( int bright )
1946 1944
1947int SIMpad::displayBrightnessResolution ( ) const 1945int 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/**************************************************
@@ -1974,9 +1963,8 @@ void Ramses::init()
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
@@ -2034,24 +2022,45 @@ void Ramses::timerEvent(QTimerEvent *)
2034 2022
2035bool Ramses::setSoftSuspend(bool soft) 2023bool Ramses::setSoftSuspend(bool soft)
2036{ 2024{
2037 Q_UNUSED(soft); 2025 qDebug("Ramses::setSoftSuspend(%d)", soft);
2038 return true; 2026#if 0
2039}
2040
2041bool 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
2060bool Ramses::suspend ( )
2061{
2062 qDebug("Ramses::suspend");
2063 return false;
2055} 2064}
2056 2065
2057/** 2066/**
@@ -2059,15 +2068,19 @@ bool Ramses::suspend()
2059 */ 2068 */
2060bool Ramses::setDisplayStatus(bool on) 2069bool 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
@@ -2076,7 +2089,7 @@ bool Ramses::setDisplayStatus(bool on)
2076*/ 2089*/
2077bool Ramses::setDisplayBrightness(int bright) 2090bool 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
@@ -2096,8 +2109,9 @@ bool Ramses::setDisplayBrightness(int bright)
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);
@@ -2109,12 +2123,12 @@ bool Ramses::setDisplayBrightness(int bright)
2109 2123
2110int Ramses::displayBrightnessResolution() const 2124int Ramses::displayBrightnessResolution() const
2111{ 2125{
2112 return 256; 2126 return 32;
2113} 2127}
2114 2128
2115bool Ramses::setDisplayContrast(int contr) 2129bool 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
@@ -2124,9 +2138,10 @@ bool Ramses::setDisplayContrast(int contr)
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);
@@ -2139,5 +2154,5 @@ bool Ramses::setDisplayContrast(int contr)
2139 2154
2140int Ramses::displayContrastResolution() const 2155int Ramses::displayContrastResolution() const
2141{ 2156{
2142 return 256; 2157 return 20;
2143} 2158}