author | sandman <sandman> | 2002-08-04 02:25:54 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-04 02:25:54 (UTC) |
commit | 8fd0780faa16abbcf7db9220af1bc333ae484ec8 (patch) (unidiff) | |
tree | ffacd596daa0ab07890f185510275667649d55db /libopie/odevice.cpp | |
parent | 549df674d7af9fe1347751e6a63d6ed8249d2503 (diff) | |
download | opie-8fd0780faa16abbcf7db9220af1bc333ae484ec8.zip opie-8fd0780faa16abbcf7db9220af1bc333ae484ec8.tar.gz opie-8fd0780faa16abbcf7db9220af1bc333ae484ec8.tar.bz2 |
1) Fixes for suspend/resume (improved it for iPAQ, shouldn't have changed
anything for Z) -- It seems that this also fixes the 70% CPU load
problem (needs more testing/feedback though)
2) the launcher now creates a /var/run/opie.pid file containing its pid
3) the launcher catches SIGTERM and kills all its child processes
-rw-r--r-- | libopie/odevice.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index bc8014a..057c344 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -16,8 +16,10 @@ | |||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stdlib.h> | ||
21 | |||
20 | #include <qfile.h> | 22 | #include <qfile.h> |
21 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
22 | #include <qpe/sound.h> | 24 | #include <qpe/sound.h> |
23 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
@@ -46,13 +48,18 @@ class ODeviceIPAQ : public ODevice { | |||
46 | protected: | 48 | protected: |
47 | virtual void init ( ); | 49 | virtual void init ( ); |
48 | 50 | ||
49 | public: | 51 | public: |
52 | virtual bool suspend ( ); | ||
53 | |||
50 | virtual void alarmSound ( ); | 54 | virtual void alarmSound ( ); |
51 | 55 | ||
52 | virtual uint hasLeds ( ) const; | 56 | virtual uint hasLeds ( ) const; |
53 | virtual OLedState led ( uint which ) const; | 57 | virtual OLedState led ( uint which ) const; |
54 | virtual bool setLed ( uint which, OLedState st ); | 58 | virtual bool setLed ( uint which, OLedState st ); |
59 | |||
60 | private: | ||
61 | static void tstp_sighandler ( int ); | ||
55 | }; | 62 | }; |
56 | 63 | ||
57 | class ODeviceZaurus : public ODevice { | 64 | class ODeviceZaurus : public ODevice { |
58 | protected: | 65 | protected: |
@@ -112,8 +119,18 @@ ODevice::~ODevice ( ) | |||
112 | { | 119 | { |
113 | delete d; | 120 | delete d; |
114 | } | 121 | } |
115 | 122 | ||
123 | bool ODevice::suspend ( ) | ||
124 | { | ||
125 | int rc = ::system ( "apm --suspend" ); | ||
126 | |||
127 | if (( rc == 127 ) || ( rc == -1 )) | ||
128 | return false; | ||
129 | else | ||
130 | return true; | ||
131 | } | ||
132 | |||
116 | QString ODevice::vendorString ( ) | 133 | QString ODevice::vendorString ( ) |
117 | { | 134 | { |
118 | return d-> m_vendorstr; | 135 | return d-> m_vendorstr; |
119 | } | 136 | } |
@@ -250,8 +267,10 @@ void ODeviceIPAQ::init ( ) | |||
250 | 267 | ||
251 | #include <unistd.h> | 268 | #include <unistd.h> |
252 | #include <fcntl.h> | 269 | #include <fcntl.h> |
253 | #include <sys/ioctl.h> | 270 | #include <sys/ioctl.h> |
271 | #include <signal.h> | ||
272 | #include <sys/time.h> | ||
254 | #include <linux/soundcard.h> | 273 | #include <linux/soundcard.h> |
255 | #include <qapplication.h> | 274 | #include <qapplication.h> |
256 | #include <qpe/config.h> | 275 | #include <qpe/config.h> |
257 | 276 | ||
@@ -269,8 +288,51 @@ typedef struct h3600_ts_led { | |||
269 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) | 288 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) |
270 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( | 289 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( |
271 | 290 | ||
272 | 291 | ||
292 | //#include <linux/apm_bios.h> | ||
293 | |||
294 | //#define APM_IOC_SUSPEND _IO('A',2) | ||
295 | |||
296 | #define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) | ||
297 | |||
298 | |||
299 | void ODeviceIPAQ::tstp_sighandler ( int ) | ||
300 | { | ||
301 | } | ||
302 | |||
303 | |||
304 | bool ODeviceIPAQ::suspend ( ) | ||
305 | { | ||
306 | int fd; | ||
307 | bool res = false; | ||
308 | |||
309 | if (( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) { | ||
310 | struct timeval tvs, tvn; | ||
311 | |||
312 | ::signal ( SIGTSTP, tstp_sighandler ); | ||
313 | ::gettimeofday ( &tvs, 0 ); | ||
314 | |||
315 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); | ||
316 | ::close ( fd ); | ||
317 | |||
318 | if ( res ) { | ||
319 | ::kill ( -::getpid ( ), SIGTSTP ); | ||
320 | |||
321 | do { | ||
322 | ::usleep ( 200 * 1000 ); | ||
323 | ::gettimeofday ( &tvn, 0 ); | ||
324 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | ||
325 | |||
326 | ::kill ( -::getpid ( ), SIGCONT ); | ||
327 | } | ||
328 | |||
329 | ::signal ( SIGTSTP, SIG_DFL ); | ||
330 | } | ||
331 | return res; | ||
332 | } | ||
333 | |||
334 | |||
273 | void ODeviceIPAQ::alarmSound ( ) | 335 | void ODeviceIPAQ::alarmSound ( ) |
274 | { | 336 | { |
275 | #if defined( QT_QWS_IPAQ ) // IPAQ | 337 | #if defined( QT_QWS_IPAQ ) // IPAQ |
276 | #ifndef QT_NO_SOUND | 338 | #ifndef QT_NO_SOUND |