author | sandman <sandman> | 2002-08-06 21:46:30 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-06 21:46:30 (UTC) |
commit | 2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b (patch) (unidiff) | |
tree | ad84f4e405da51a6ca14ab4dd33bfd7c9f2a411e | |
parent | 8084d002de5e310491eec7fac0713ef29d0cf30f (diff) | |
download | opie-2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b.zip opie-2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b.tar.gz opie-2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b.tar.bz2 |
- Fix for the "iPAQ won't suspend until apm --suspend is called" problem
- Improved the resume delay until the LCD backlight is on again
-rw-r--r-- | core/launcher/desktop.cpp | 12 | ||||
-rw-r--r-- | libopie/odevice.cpp | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 7f24259..552c7c3 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -575,86 +575,90 @@ void Desktop::execAutoStart() { | |||
575 | 575 | ||
576 | #include <sys/ioctl.h> | 576 | #include <sys/ioctl.h> |
577 | #include <sys/types.h> | 577 | #include <sys/types.h> |
578 | #include <fcntl.h> | 578 | #include <fcntl.h> |
579 | #include <unistd.h> | 579 | #include <unistd.h> |
580 | #include <errno.h> | 580 | #include <errno.h> |
581 | #include <linux/ioctl.h> | 581 | #include <linux/ioctl.h> |
582 | #include <time.h> | 582 | #include <time.h> |
583 | #endif | 583 | #endif |
584 | 584 | ||
585 | static bool blanked=FALSE; | 585 | static bool blanked=FALSE; |
586 | 586 | ||
587 | static void blankScreen() | 587 | static void blankScreen() |
588 | { | 588 | { |
589 | if ( !qt_screen ) return; | 589 | if ( !qt_screen ) return; |
590 | /* Should use a big black window instead. | 590 | /* Should use a big black window instead. |
591 | QGfx* g = qt_screen->screenGfx(); | 591 | QGfx* g = qt_screen->screenGfx(); |
592 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); | 592 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); |
593 | delete g; | 593 | delete g; |
594 | */ | 594 | */ |
595 | blanked = TRUE; | 595 | blanked = TRUE; |
596 | } | 596 | } |
597 | 597 | ||
598 | static void darkScreen() | 598 | static void darkScreen() |
599 | { | 599 | { |
600 | extern void qpe_setBacklight(int); | 600 | extern void qpe_setBacklight(int); |
601 | qpe_setBacklight(0); // force off | 601 | qpe_setBacklight(0); // force off |
602 | } | 602 | } |
603 | 603 | ||
604 | 604 | ||
605 | void Desktop::togglePower() | 605 | void Desktop::togglePower() |
606 | { | 606 | { |
607 | extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop | ||
608 | |||
607 | static bool excllock = false; | 609 | static bool excllock = false; |
608 | 610 | ||
609 | if ( excllock ) | 611 | if ( excllock ) |
610 | return; | 612 | return; |
611 | 613 | ||
612 | excllock = true; | 614 | excllock = true; |
613 | 615 | ||
614 | bool wasloggedin = loggedin; | 616 | bool wasloggedin = loggedin; |
615 | loggedin=0; | 617 | loggedin=0; |
616 | suspendTime = QDateTime::currentDateTime(); | 618 | suspendTime = QDateTime::currentDateTime(); |
617 | darkScreen(); | 619 | |
620 | qpe_setBacklight ( 0 ); // force LCD off | ||
621 | |||
618 | if ( wasloggedin ) | 622 | if ( wasloggedin ) |
619 | blankScreen(); | 623 | blankScreen(); |
620 | 624 | ||
621 | ODevice::inst ( )-> suspend ( ); | 625 | ODevice::inst ( )-> suspend ( ); |
622 | 626 | ||
623 | QWSServer::screenSaverActivate( FALSE ); | 627 | QWSServer::screenSaverActivate ( false ); |
628 | |||
629 | qpe_setBacklight ( -3 ); // force LCD on | ||
624 | 630 | ||
625 | { | 631 | { |
626 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 632 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
627 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | ||
628 | e << -3; // Force on | ||
629 | } | 633 | } |
630 | 634 | ||
631 | if ( wasloggedin ) | 635 | if ( wasloggedin ) |
632 | login(TRUE); | 636 | login(TRUE); |
633 | 637 | ||
634 | execAutoStart(); | 638 | execAutoStart(); |
635 | //qcopBridge->closeOpenConnections(); | 639 | //qcopBridge->closeOpenConnections(); |
636 | //qDebug("called togglePower()!!!!!!"); | 640 | //qDebug("called togglePower()!!!!!!"); |
637 | 641 | ||
638 | qApp-> processEvents ( ); | 642 | qApp-> processEvents ( ); |
639 | 643 | ||
640 | excllock = false; | 644 | excllock = false; |
641 | } | 645 | } |
642 | 646 | ||
643 | void Desktop::toggleLight() | 647 | void Desktop::toggleLight() |
644 | { | 648 | { |
645 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 649 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
646 | e << -2; // toggle | 650 | e << -2; // toggle |
647 | } | 651 | } |
648 | 652 | ||
649 | void Desktop::toggleSymbolInput() | 653 | void Desktop::toggleSymbolInput() |
650 | { | 654 | { |
651 | tb->toggleSymbolInput(); | 655 | tb->toggleSymbolInput(); |
652 | } | 656 | } |
653 | 657 | ||
654 | void Desktop::toggleNumLockState() | 658 | void Desktop::toggleNumLockState() |
655 | { | 659 | { |
656 | tb->toggleNumLockState(); | 660 | tb->toggleNumLockState(); |
657 | } | 661 | } |
658 | 662 | ||
659 | void Desktop::toggleCapsLockState() | 663 | void Desktop::toggleCapsLockState() |
660 | { | 664 | { |
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 057c344..bf64676 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -277,86 +277,88 @@ void ODeviceIPAQ::init ( ) | |||
277 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 277 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
278 | 278 | ||
279 | typedef struct h3600_ts_led { | 279 | typedef struct h3600_ts_led { |
280 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 280 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
281 | unsigned char TotalTime; /* Units of 5 seconds */ | 281 | unsigned char TotalTime; /* Units of 5 seconds */ |
282 | unsigned char OnTime; /* units of 100m/s */ | 282 | unsigned char OnTime; /* units of 100m/s */ |
283 | unsigned char OffTime; /* units of 100m/s */ | 283 | unsigned char OffTime; /* units of 100m/s */ |
284 | } LED_IN; | 284 | } LED_IN; |
285 | 285 | ||
286 | 286 | ||
287 | // #define IOC_H3600_TS_MAGIC 'f' | 287 | // #define IOC_H3600_TS_MAGIC 'f' |
288 | // #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) |
289 | #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 :( |
290 | 290 | ||
291 | 291 | ||
292 | //#include <linux/apm_bios.h> | 292 | //#include <linux/apm_bios.h> |
293 | 293 | ||
294 | //#define APM_IOC_SUSPEND _IO('A',2) | 294 | //#define APM_IOC_SUSPEND _IO('A',2) |
295 | 295 | ||
296 | #define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) | 296 | #define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) |
297 | 297 | ||
298 | 298 | ||
299 | void ODeviceIPAQ::tstp_sighandler ( int ) | 299 | void ODeviceIPAQ::tstp_sighandler ( int ) |
300 | { | 300 | { |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | bool ODeviceIPAQ::suspend ( ) | 304 | bool ODeviceIPAQ::suspend ( ) |
305 | { | 305 | { |
306 | int fd; | 306 | int fd; |
307 | bool res = false; | 307 | bool res = false; |
308 | 308 | ||
309 | if (( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) { | 309 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
310 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | ||
310 | struct timeval tvs, tvn; | 311 | struct timeval tvs, tvn; |
311 | 312 | ||
312 | ::signal ( SIGTSTP, tstp_sighandler ); | 313 | ::signal ( SIGTSTP, tstp_sighandler ); |
313 | ::gettimeofday ( &tvs, 0 ); | 314 | ::gettimeofday ( &tvs, 0 ); |
314 | 315 | ||
315 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); | 316 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); |
316 | ::close ( fd ); | 317 | ::close ( fd ); |
317 | 318 | ||
318 | if ( res ) { | 319 | if ( res ) { |
319 | ::kill ( -::getpid ( ), SIGTSTP ); | 320 | ::kill ( -::getpid ( ), SIGTSTP ); |
320 | 321 | ||
321 | do { | 322 | do { |
322 | ::usleep ( 200 * 1000 ); | 323 | ::usleep ( 200 * 1000 ); |
323 | ::gettimeofday ( &tvn, 0 ); | 324 | ::gettimeofday ( &tvn, 0 ); |
324 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 325 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
325 | 326 | ||
326 | ::kill ( -::getpid ( ), SIGCONT ); | 327 | ::kill ( -::getpid ( ), SIGCONT ); |
327 | } | 328 | } |
328 | 329 | ||
329 | ::signal ( SIGTSTP, SIG_DFL ); | 330 | ::signal ( SIGTSTP, SIG_DFL ); |
330 | } | 331 | } |
332 | |||
331 | return res; | 333 | return res; |
332 | } | 334 | } |
333 | 335 | ||
334 | 336 | ||
335 | void ODeviceIPAQ::alarmSound ( ) | 337 | void ODeviceIPAQ::alarmSound ( ) |
336 | { | 338 | { |
337 | #if defined( QT_QWS_IPAQ ) // IPAQ | 339 | #if defined( QT_QWS_IPAQ ) // IPAQ |
338 | #ifndef QT_NO_SOUND | 340 | #ifndef QT_NO_SOUND |
339 | static Sound snd ( "alarm" ); | 341 | static Sound snd ( "alarm" ); |
340 | int fd; | 342 | int fd; |
341 | int vol; | 343 | int vol; |
342 | bool vol_reset = false; | 344 | bool vol_reset = false; |
343 | 345 | ||
344 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || | 346 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || |
345 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { | 347 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { |
346 | 348 | ||
347 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 349 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
348 | Config cfg ( "qpe" ); | 350 | Config cfg ( "qpe" ); |
349 | cfg. setGroup ( "Volume" ); | 351 | cfg. setGroup ( "Volume" ); |
350 | 352 | ||
351 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 353 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
352 | if ( volalarm < 0 ) | 354 | if ( volalarm < 0 ) |
353 | volalarm = 0; | 355 | volalarm = 0; |
354 | else if ( volalarm > 100 ) | 356 | else if ( volalarm > 100 ) |
355 | volalarm = 100; | 357 | volalarm = 100; |
356 | volalarm |= ( volalarm << 8 ); | 358 | volalarm |= ( volalarm << 8 ); |
357 | 359 | ||
358 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 360 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
359 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 361 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
360 | vol_reset = true; | 362 | vol_reset = true; |
361 | } | 363 | } |
362 | } | 364 | } |