summaryrefslogtreecommitdiff
path: root/libopie
authormickeyl <mickeyl>2003-12-08 15:17:16 (UTC)
committer mickeyl <mickeyl>2003-12-08 15:17:16 (UTC)
commit7f2f736597490fd1592d7ed1f40e4abf824673c0 (patch) (unidiff)
tree542b6f52b3556f1f4f04c18c15446c73a867ebdc /libopie
parentb1182e6a5069c7109f824a916e566c9c1954ded8 (diff)
downloadopie-7f2f736597490fd1592d7ed1f40e4abf824673c0.zip
opie-7f2f736597490fd1592d7ed1f40e4abf824673c0.tar.gz
opie-7f2f736597490fd1592d7ed1f40e4abf824673c0.tar.bz2
Rot270 is not a Direction, but a Rotation. treke, is this fix correct?
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 5038cc9..e24e043 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1914,272 +1914,272 @@ bool Zaurus::setSoftSuspend ( bool soft )
1914 1914
1915 bool res = false; 1915 bool res = false;
1916 int fd; 1916 int fd;
1917 1917
1918 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1918 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1919 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1919 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1920 1920
1921 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1921 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1922 1922
1923 if ( sources >= 0 ) { 1923 if ( sources >= 0 ) {
1924 if ( soft ) 1924 if ( soft )
1925 sources &= ~APM_EVT_POWER_BUTTON; 1925 sources &= ~APM_EVT_POWER_BUTTON;
1926 else 1926 else
1927 sources |= APM_EVT_POWER_BUTTON; 1927 sources |= APM_EVT_POWER_BUTTON;
1928 1928
1929 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1929 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1930 res = true; 1930 res = true;
1931 else 1931 else
1932 perror ( "APM_IOCGEVTSRC" ); 1932 perror ( "APM_IOCGEVTSRC" );
1933 } 1933 }
1934 else 1934 else
1935 perror ( "APM_IOCGEVTSRC" ); 1935 perror ( "APM_IOCGEVTSRC" );
1936 1936
1937 ::close ( fd ); 1937 ::close ( fd );
1938 } 1938 }
1939 else 1939 else
1940 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1940 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1941 1941
1942 return res; 1942 return res;
1943} 1943}
1944 1944
1945 1945
1946bool Zaurus::setDisplayBrightness ( int bright ) 1946bool Zaurus::setDisplayBrightness ( int bright )
1947{ 1947{
1948// FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which 1948// FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which
1949// is nice to use. Currently it exposes 16+1 levels. Implement this! 1949// is nice to use. Currently it exposes 16+1 levels. Implement this!
1950// (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.) 1950// (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.)
1951 bool res = false; 1951 bool res = false;
1952 int fd; 1952 int fd;
1953 1953
1954 if ( bright > 255 ) 1954 if ( bright > 255 )
1955 bright = 255; 1955 bright = 255;
1956 if ( bright < 0 ) 1956 if ( bright < 0 )
1957 bright = 0; 1957 bright = 0;
1958 1958
1959 if (m_embedix) { 1959 if (m_embedix) {
1960 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1960 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1961 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1961 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1962 if ( bright && !bl ) 1962 if ( bright && !bl )
1963 bl = 1; 1963 bl = 1;
1964 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1964 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1965 ::close ( fd ); 1965 ::close ( fd );
1966 } 1966 }
1967 } else { 1967 } else {
1968#define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 1968#define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
1969 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 1969 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
1970 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 1970 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
1971 ::close ( fd ); 1971 ::close ( fd );
1972 } 1972 }
1973 } 1973 }
1974 return res; 1974 return res;
1975} 1975}
1976 1976
1977bool Zaurus::suspend ( ) 1977bool Zaurus::suspend ( )
1978{ 1978{
1979 qDebug("ODevice::suspend"); 1979 qDebug("ODevice::suspend");
1980 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 1980 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1981 return false; 1981 return false;
1982 1982
1983 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 1983 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
1984 return false; 1984 return false;
1985 1985
1986 bool res = false; 1986 bool res = false;
1987 1987
1988 struct timeval tvs, tvn; 1988 struct timeval tvs, tvn;
1989 ::gettimeofday ( &tvs, 0 ); 1989 ::gettimeofday ( &tvs, 0 );
1990 1990
1991 ::sync ( ); // flush fs caches 1991 ::sync ( ); // flush fs caches
1992 res = ( ::system ( "apm --suspend" ) == 0 ); 1992 res = ( ::system ( "apm --suspend" ) == 0 );
1993 1993
1994 // This is needed because the iPAQ apm implementation is asynchronous and we 1994 // This is needed because the iPAQ apm implementation is asynchronous and we
1995 // can not be sure when exactly the device is really suspended 1995 // can not be sure when exactly the device is really suspended
1996 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 1996 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
1997 1997
1998 if ( res ) { 1998 if ( res ) {
1999 do { // Yes, wait 15 seconds. This APM bug sucks big time. 1999 do { // Yes, wait 15 seconds. This APM bug sucks big time.
2000 ::usleep ( 200 * 1000 ); 2000 ::usleep ( 200 * 1000 );
2001 ::gettimeofday ( &tvn, 0 ); 2001 ::gettimeofday ( &tvn, 0 );
2002 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 2002 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
2003 } 2003 }
2004 2004
2005 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 2005 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
2006 return res; 2006 return res;
2007} 2007}
2008 2008
2009 2009
2010Transformation Zaurus::rotation ( ) const 2010Transformation Zaurus::rotation ( ) const
2011{ 2011{
2012 Transformation rot; 2012 Transformation rot;
2013 int handle = 0; 2013 int handle = 0;
2014 int retval = 0; 2014 int retval = 0;
2015 2015
2016 switch ( d-> m_model ) { 2016 switch ( d-> m_model ) {
2017 case Model_Zaurus_SLC7x0: 2017 case Model_Zaurus_SLC7x0:
2018 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2018 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2019 if (handle == -1) { 2019 if (handle == -1) {
2020 return Rot270; 2020 return Rot270;
2021 } else { 2021 } else {
2022 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2022 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2023 ::close (handle); 2023 ::close (handle);
2024 2024
2025 if (retval == 2 ) 2025 if (retval == 2 )
2026 rot = Rot0; 2026 rot = Rot0;
2027 else 2027 else
2028 rot = Rot270; 2028 rot = Rot270;
2029 } 2029 }
2030 break; 2030 break;
2031 case Model_Zaurus_SLA300: 2031 case Model_Zaurus_SLA300:
2032 case Model_Zaurus_SLB600: 2032 case Model_Zaurus_SLB600:
2033 case Model_Zaurus_SL5500: 2033 case Model_Zaurus_SL5500:
2034 case Model_Zaurus_SL5000: 2034 case Model_Zaurus_SL5000:
2035 default: 2035 default:
2036 rot = d-> m_rotation; 2036 rot = d-> m_rotation;
2037 break; 2037 break;
2038 } 2038 }
2039 2039
2040 return rot; 2040 return rot;
2041} 2041}
2042ODirection Zaurus::direction ( ) const 2042ODirection Zaurus::direction ( ) const
2043{ 2043{
2044 ODirection dir; 2044 ODirection dir;
2045 int handle = 0; 2045 int handle = 0;
2046 int retval = 0; 2046 int retval = 0;
2047 switch ( d-> m_model ) { 2047 switch ( d-> m_model ) {
2048 case Model_Zaurus_SLC7x0: 2048 case Model_Zaurus_SLC7x0:
2049 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2049 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2050 if (handle == -1) { 2050 if (handle == -1) {
2051 dir = Rot270; 2051 dir = CW;
2052 } else { 2052 } else {
2053 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2053 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2054 ::close (handle); 2054 ::close (handle);
2055 if (retval == 2 ) 2055 if (retval == 2 )
2056 dir = CCW; 2056 dir = CCW;
2057 else 2057 else
2058 dir = CW; 2058 dir = CW;
2059 } 2059 }
2060 break; 2060 break;
2061 case Model_Zaurus_SLA300: 2061 case Model_Zaurus_SLA300:
2062 case Model_Zaurus_SLB600: 2062 case Model_Zaurus_SLB600:
2063 case Model_Zaurus_SL5500: 2063 case Model_Zaurus_SL5500:
2064 case Model_Zaurus_SL5000: 2064 case Model_Zaurus_SL5000:
2065 default: 2065 default:
2066 dir = d-> m_direction; 2066 dir = d-> m_direction;
2067 break; 2067 break;
2068 } 2068 }
2069 return dir; 2069 return dir;
2070 2070
2071} 2071}
2072 2072
2073int Zaurus::displayBrightnessResolution ( ) const 2073int Zaurus::displayBrightnessResolution ( ) const
2074{ 2074{
2075 if (m_embedix) 2075 if (m_embedix)
2076 return 5; 2076 return 5;
2077 else 2077 else
2078 return 256; 2078 return 256;
2079} 2079}
2080 2080
2081/************************************************** 2081/**************************************************
2082 * 2082 *
2083 * SIMpad 2083 * SIMpad
2084 * 2084 *
2085 **************************************************/ 2085 **************************************************/
2086 2086
2087void SIMpad::init ( ) 2087void SIMpad::init ( )
2088{ 2088{
2089 d-> m_vendorstr = "SIEMENS"; 2089 d-> m_vendorstr = "SIEMENS";
2090 d-> m_vendor = Vendor_SIEMENS; 2090 d-> m_vendor = Vendor_SIEMENS;
2091 2091
2092 QFile f ( "/proc/hal/model" ); 2092 QFile f ( "/proc/hal/model" );
2093 2093
2094 //TODO Implement model checking 2094 //TODO Implement model checking
2095 //FIXME For now we assume an SL4 2095 //FIXME For now we assume an SL4
2096 2096
2097 d-> m_modelstr = "SL4"; 2097 d-> m_modelstr = "SL4";
2098 d-> m_model = Model_SIMpad_SL4; 2098 d-> m_model = Model_SIMpad_SL4;
2099 2099
2100 switch ( d-> m_model ) { 2100 switch ( d-> m_model ) {
2101 default: 2101 default:
2102 d-> m_rotation = Rot0; 2102 d-> m_rotation = Rot0;
2103 d-> m_direction = CCW; 2103 d-> m_direction = CCW;
2104 d-> m_holdtime = 1000; // 1000ms 2104 d-> m_holdtime = 1000; // 1000ms
2105 2105
2106 break; 2106 break;
2107 } 2107 }
2108 2108
2109 f. setName ( "/etc/familiar-version" ); 2109 f. setName ( "/etc/familiar-version" );
2110 if ( f. open ( IO_ReadOnly )) { 2110 if ( f. open ( IO_ReadOnly )) {
2111 d-> m_systemstr = "Familiar"; 2111 d-> m_systemstr = "Familiar";
2112 d-> m_system = System_Familiar; 2112 d-> m_system = System_Familiar;
2113 2113
2114 QTextStream ts ( &f ); 2114 QTextStream ts ( &f );
2115 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 2115 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
2116 2116
2117 f. close ( ); 2117 f. close ( );
2118 } else { 2118 } else {
2119 f. setName ( "/etc/oz_version" ); 2119 f. setName ( "/etc/oz_version" );
2120 2120
2121 if ( f. open ( IO_ReadOnly )) { 2121 if ( f. open ( IO_ReadOnly )) {
2122 d-> m_systemstr = "OpenEmbedded/SIMpad"; 2122 d-> m_systemstr = "OpenEmbedded/SIMpad";
2123 d-> m_system = System_OpenZaurus; 2123 d-> m_system = System_OpenZaurus;
2124 2124
2125 QTextStream ts ( &f ); 2125 QTextStream ts ( &f );
2126 ts.setDevice ( &f ); 2126 ts.setDevice ( &f );
2127 d-> m_sysverstr = ts. readLine ( ); 2127 d-> m_sysverstr = ts. readLine ( );
2128 f. close ( ); 2128 f. close ( );
2129 } 2129 }
2130 } 2130 }
2131 2131
2132 m_leds [0] = m_leds [1] = Led_Off; 2132 m_leds [0] = m_leds [1] = Led_Off;
2133 2133
2134 m_power_timer = 0; 2134 m_power_timer = 0;
2135 2135
2136} 2136}
2137 2137
2138void SIMpad::initButtons ( ) 2138void SIMpad::initButtons ( )
2139{ 2139{
2140 if ( d-> m_buttons ) 2140 if ( d-> m_buttons )
2141 return; 2141 return;
2142 2142
2143 if ( isQWS( ) ) 2143 if ( isQWS( ) )
2144 QWSServer::setKeyboardFilter ( this ); 2144 QWSServer::setKeyboardFilter ( this );
2145 2145
2146 d-> m_buttons = new QValueList <ODeviceButton>; 2146 d-> m_buttons = new QValueList <ODeviceButton>;
2147 2147
2148 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 2148 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
2149 s_button *sb = simpad_buttons + i; 2149 s_button *sb = simpad_buttons + i;
2150 ODeviceButton b; 2150 ODeviceButton b;
2151 2151
2152 if (( sb-> model & d-> m_model ) == d-> m_model ) { 2152 if (( sb-> model & d-> m_model ) == d-> m_model ) {
2153 b. setKeycode ( sb-> code ); 2153 b. setKeycode ( sb-> code );
2154 b. setUserText ( QObject::tr ( "Button", sb-> utext )); 2154 b. setUserText ( QObject::tr ( "Button", sb-> utext ));
2155 b. setPixmap ( Resource::loadPixmap ( sb-> pix )); 2155 b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
2156 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); 2156 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
2157 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); 2157 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
2158 2158
2159 d-> m_buttons-> append ( b ); 2159 d-> m_buttons-> append ( b );
2160 } 2160 }
2161 } 2161 }
2162 reloadButtonMapping ( ); 2162 reloadButtonMapping ( );
2163 2163
2164 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 2164 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
2165 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 2165 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
2166} 2166}
2167 2167
2168// SIMpad boardcontrol register CS3 2168// SIMpad boardcontrol register CS3
2169#define SIMPAD_BOARDCONTROL "/proc/cs3" 2169#define SIMPAD_BOARDCONTROL "/proc/cs3"
2170#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 2170#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
2171#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 2171#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
2172#define SIMPAD_EN1 0x0004 // This is only for EPROM's 2172#define SIMPAD_EN1 0x0004 // This is only for EPROM's
2173#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 2173#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
2174#define SIMPAD_DISPLAY_ON 0x0010 2174#define SIMPAD_DISPLAY_ON 0x0010
2175#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 2175#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
2176#define SIMPAD_MQ_RESET 0x0040 2176#define SIMPAD_MQ_RESET 0x0040
2177#define SIMPAD_PCMCIA_RESET 0x0080 2177#define SIMPAD_PCMCIA_RESET 0x0080
2178#define SIMPAD_DECT_POWER_ON 0x0100 2178#define SIMPAD_DECT_POWER_ON 0x0100
2179#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 2179#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
2180#define SIMPAD_RS232_ON 0x0400 2180#define SIMPAD_RS232_ON 0x0400
2181#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 2181#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
2182#define SIMPAD_LED2_ON 0x1000 2182#define SIMPAD_LED2_ON 0x1000
2183#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 2183#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
2184#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 2184#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
2185#define SIMPAD_RESET_SIMCARD 0x8000 2185#define SIMPAD_RESET_SIMCARD 0x8000