summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-30 02:17:25 (UTC)
committer mickeyl <mickeyl>2003-12-30 02:17:25 (UTC)
commitb53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a (patch) (unidiff)
tree98db0a0053c53e98ba758773f80ad8e14c9564c9
parentb636d3d91e8456b22bc450b3d7f3a862b7f615a9 (diff)
downloadopie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.zip
opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.tar.gz
opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.tar.bz2
fix a problem in the c7x0 backlight handling...
Bah! Got confused by the input interval for ODevice::setDisplayBrightness() (once) again - it has been ridiculous to scale that down from [0-255] to the actual interval since the day we invented ODevice::displayBrightnessResolution(). I'm going to remove that antique cruft soon.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/odevice.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index bc09e92..82a0099 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1919,112 +1919,114 @@ bool Zaurus::setLedState ( OLed which, OLedState st )
1919 m_leds [0] = st; 1919 m_leds [0] = st;
1920 return true; 1920 return true;
1921 } 1921 }
1922 } 1922 }
1923 } 1923 }
1924 return false; 1924 return false;
1925} 1925}
1926 1926
1927bool Zaurus::setSoftSuspend ( bool soft ) 1927bool Zaurus::setSoftSuspend ( bool soft )
1928{ 1928{
1929 if (!m_embedix) { 1929 if (!m_embedix) {
1930 /* non-Embedix kernels dont have kernel autosuspend */ 1930 /* non-Embedix kernels dont have kernel autosuspend */
1931 return ODevice::setSoftSuspend( soft ); 1931 return ODevice::setSoftSuspend( soft );
1932 } 1932 }
1933 1933
1934 bool res = false; 1934 bool res = false;
1935 int fd; 1935 int fd;
1936 1936
1937 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1937 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1938 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1938 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1939 1939
1940 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1940 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1941 1941
1942 if ( sources >= 0 ) { 1942 if ( sources >= 0 ) {
1943 if ( soft ) 1943 if ( soft )
1944 sources &= ~APM_EVT_POWER_BUTTON; 1944 sources &= ~APM_EVT_POWER_BUTTON;
1945 else 1945 else
1946 sources |= APM_EVT_POWER_BUTTON; 1946 sources |= APM_EVT_POWER_BUTTON;
1947 1947
1948 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1948 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1949 res = true; 1949 res = true;
1950 else 1950 else
1951 perror ( "APM_IOCGEVTSRC" ); 1951 perror ( "APM_IOCGEVTSRC" );
1952 } 1952 }
1953 else 1953 else
1954 perror ( "APM_IOCGEVTSRC" ); 1954 perror ( "APM_IOCGEVTSRC" );
1955 1955
1956 ::close ( fd ); 1956 ::close ( fd );
1957 } 1957 }
1958 else 1958 else
1959 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1959 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1960 1960
1961 return res; 1961 return res;
1962} 1962}
1963 1963
1964 1964
1965bool Zaurus::setDisplayBrightness ( int bright ) 1965bool Zaurus::setDisplayBrightness ( int bright )
1966{ 1966{
1967 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
1967 bool res = false; 1968 bool res = false;
1968 int fd; 1969 int fd;
1969 1970
1970 if ( bright > 255 ) bright = 255; 1971 if ( bright > 255 ) bright = 255;
1971 if ( bright < 0 ) bright = 0; 1972 if ( bright < 0 ) bright = 0;
1972 1973
1973 if ( m_embedix ) 1974 if ( m_embedix )
1974 { 1975 {
1975 if ( d->m_model == Model_Zaurus_SLC7x0 ) 1976 if ( d->m_model == Model_Zaurus_SLC7x0 )
1976 { 1977 {
1978 //qDebug( "using special treatment for devices with the corgi backlight interface" );
1977 // special treatment for devices with the corgi backlight interface 1979 // special treatment for devices with the corgi backlight interface
1978 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 1980 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
1979 { 1981 {
1980 if ( bright > 0x11 ) bright = 0x11; 1982 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 );
1981 char writeCommand[100]; 1983 char writeCommand[100];
1982 const int count = sprintf( writeCommand, "0x%x\n", bright ); 1984 const int count = sprintf( writeCommand, "0x%x\n", value );
1983 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1985 res = ( ::write ( fd, writeCommand, count ) != -1 );
1984 ::close ( fd ); 1986 ::close ( fd );
1985 } 1987 }
1986 return res; 1988 return res;
1987 } 1989 }
1988 else 1990 else
1989 { 1991 {
1990 // standard treatment for devices with the dumb embedix frontlight interface 1992 // standard treatment for devices with the dumb embedix frontlight interface
1991 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1993 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1992 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1994 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1993 if ( bright && !bl ) 1995 if ( bright && !bl )
1994 bl = 1; 1996 bl = 1;
1995 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1997 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1996 ::close ( fd ); 1998 ::close ( fd );
1997 } 1999 }
1998 } 2000 }
1999 } 2001 }
2000 else 2002 else
2001 { 2003 {
2002 // special treatment for the OpenZaurus unified interface 2004 // special treatment for the OpenZaurus unified interface
2003 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 2005 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
2004 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 2006 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
2005 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 2007 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
2006 ::close ( fd ); 2008 ::close ( fd );
2007 } 2009 }
2008 } 2010 }
2009 return res; 2011 return res;
2010} 2012}
2011 2013
2012bool Zaurus::suspend ( ) 2014bool Zaurus::suspend ( )
2013{ 2015{
2014 qDebug("ODevice::suspend"); 2016 qDebug("ODevice::suspend");
2015 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 2017 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
2016 return false; 2018 return false;
2017 2019
2018 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 2020 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
2019 return false; 2021 return false;
2020 2022
2021 bool res = false; 2023 bool res = false;
2022 2024
2023 struct timeval tvs, tvn; 2025 struct timeval tvs, tvn;
2024 ::gettimeofday ( &tvs, 0 ); 2026 ::gettimeofday ( &tvs, 0 );
2025 2027
2026 ::sync ( ); // flush fs caches 2028 ::sync ( ); // flush fs caches
2027 res = ( ::system ( "apm --suspend" ) == 0 ); 2029 res = ( ::system ( "apm --suspend" ) == 0 );
2028 2030
2029 // This is needed because the iPAQ apm implementation is asynchronous and we 2031 // This is needed because the iPAQ apm implementation is asynchronous and we
2030 // can not be sure when exactly the device is really suspended 2032 // can not be sure when exactly the device is really suspended