summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
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
@@ -473,4 +473,7 @@ void ODevice::initButtons ( )
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}
@@ -786,5 +789,5 @@ const QStrList &ODevice::allowedCpuFrequencies ( ) const
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 */
@@ -921,9 +924,7 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
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
@@ -1649,5 +1650,4 @@ int Zaurus::displayBrightnessResolution ( ) const
1649} 1650}
1650 1651
1651
1652/************************************************** 1652/**************************************************
1653 * 1653 *
@@ -1890,5 +1890,5 @@ bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
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;
@@ -1912,8 +1912,6 @@ bool SIMpad::setDisplayStatus ( bool on )
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}
@@ -1928,5 +1926,5 @@ bool SIMpad::setDisplayBrightness ( int bright )
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
@@ -1947,14 +1945,5 @@ bool SIMpad::setDisplayBrightness ( int bright )
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
@@ -1975,7 +1964,6 @@ void Ramses::init()
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");
@@ -2035,22 +2023,43 @@ void Ramses::timerEvent(QTimerEvent *)
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
@@ -2060,13 +2069,17 @@ bool Ramses::suspend()
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
@@ -2077,5 +2090,5 @@ bool Ramses::setDisplayStatus(bool on)
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;
@@ -2097,6 +2110,7 @@ bool Ramses::setDisplayBrightness(int bright)
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);
@@ -2110,10 +2124,10 @@ bool Ramses::setDisplayBrightness(int bright)
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;
@@ -2125,7 +2139,8 @@ bool Ramses::setDisplayContrast(int contr)
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);
@@ -2140,4 +2155,4 @@ bool Ramses::setDisplayContrast(int contr)
2140int Ramses::displayContrastResolution() const 2155int Ramses::displayContrastResolution() const
2141{ 2156{
2142 return 256; 2157 return 20;
2143} 2158}