-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index a59e799..7377965 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -471,106 +471,119 @@ bool Zaurus::setDisplayStatus( bool on ) | |||
471 | { | 471 | { |
472 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); | 472 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); |
473 | if ( fd ) | 473 | if ( fd ) |
474 | { | 474 | { |
475 | char buf[10]; | 475 | char buf[10]; |
476 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 476 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
477 | buf[1] = '\0'; | 477 | buf[1] = '\0'; |
478 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 478 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
479 | ::close( fd ); | 479 | ::close( fd ); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | return res; | 482 | return res; |
483 | } | 483 | } |
484 | 484 | ||
485 | bool Zaurus::suspend() | 485 | bool Zaurus::suspend() |
486 | { | 486 | { |
487 | qDebug("ODevice::suspend"); | 487 | qDebug("ODevice::suspend"); |
488 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 488 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
489 | return false; | 489 | return false; |
490 | 490 | ||
491 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 491 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
492 | return false; | 492 | return false; |
493 | 493 | ||
494 | bool res = false; | 494 | bool res = false; |
495 | ODevice::sendSuspendmsg(); | 495 | ODevice::sendSuspendmsg(); |
496 | 496 | ||
497 | struct timeval tvs, tvn; | 497 | struct timeval tvs, tvn; |
498 | ::gettimeofday ( &tvs, 0 ); | 498 | ::gettimeofday ( &tvs, 0 ); |
499 | 499 | ||
500 | ::sync(); // flush fs caches | 500 | ::sync(); // flush fs caches |
501 | res = ( ::system ( "apm --suspend" ) == 0 ); | 501 | res = ( ::system ( "apm --suspend" ) == 0 ); |
502 | 502 | ||
503 | // This is needed because the apm implementation is asynchronous and we | 503 | // This is needed because the apm implementation is asynchronous and we |
504 | // can not be sure when exactly the device is really suspended | 504 | // can not be sure when exactly the device is really suspended |
505 | if ( res ) { | 505 | if ( res ) { |
506 | do { // Yes, wait 15 seconds. This APM sucks big time. | 506 | do { // Yes, wait 15 seconds. This APM sucks big time. |
507 | ::usleep ( 200 * 1000 ); | 507 | ::usleep ( 200 * 1000 ); |
508 | ::gettimeofday ( &tvn, 0 ); | 508 | ::gettimeofday ( &tvn, 0 ); |
509 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 509 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
510 | } | 510 | } |
511 | 511 | ||
512 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 512 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
513 | return res; | 513 | return res; |
514 | } | 514 | } |
515 | 515 | ||
516 | 516 | ||
517 | Transformation Zaurus::rotation() const | 517 | Transformation Zaurus::rotation() const |
518 | { | 518 | { |
519 | qDebug( "Zaurus::rotation()" ); | ||
519 | Transformation rot; | 520 | Transformation rot; |
520 | 521 | ||
521 | switch ( d->m_model ) { | 522 | switch ( d->m_model ) { |
522 | case Model_Zaurus_SLC3000: // fallthrough | 523 | case Model_Zaurus_SLC3000: // fallthrough |
523 | case Model_Zaurus_SLC7x0: { | 524 | case Model_Zaurus_SLC7x0: |
524 | OHingeStatus hs = readHingeSensor(); | 525 | { |
526 | OHingeStatus hs = readHingeSensor(); | ||
527 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | ||
528 | |||
529 | if ( m_embedix ) | ||
530 | { | ||
525 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 531 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
526 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 532 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
527 | else rot = Rot270; | 533 | else rot = Rot270; |
528 | } | 534 | } |
535 | else | ||
536 | { | ||
537 | if ( hs == CASE_PORTRAIT ) rot = Rot270; | ||
538 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | ||
539 | else rot = Rot0; | ||
540 | } | ||
541 | } | ||
529 | break; | 542 | break; |
530 | case Model_Zaurus_SL6000: | 543 | case Model_Zaurus_SL6000: |
531 | case Model_Zaurus_SLB600: | 544 | case Model_Zaurus_SLB600: |
532 | case Model_Zaurus_SLA300: | 545 | case Model_Zaurus_SLA300: |
533 | case Model_Zaurus_SL5500: | 546 | case Model_Zaurus_SL5500: |
534 | case Model_Zaurus_SL5000: | 547 | case Model_Zaurus_SL5000: |
535 | default: | 548 | default: |
536 | rot = d->m_rotation; | 549 | rot = d->m_rotation; |
537 | break; | 550 | break; |
538 | } | 551 | } |
539 | 552 | ||
540 | return rot; | 553 | return rot; |
541 | } | 554 | } |
542 | ODirection Zaurus::direction() const | 555 | ODirection Zaurus::direction() const |
543 | { | 556 | { |
544 | ODirection dir; | 557 | ODirection dir; |
545 | 558 | ||
546 | switch ( d->m_model ) { | 559 | switch ( d->m_model ) { |
547 | case Model_Zaurus_SLC3000: // fallthrough | 560 | case Model_Zaurus_SLC3000: // fallthrough |
548 | case Model_Zaurus_SLC7x0: { | 561 | case Model_Zaurus_SLC7x0: { |
549 | OHingeStatus hs = readHingeSensor(); | 562 | OHingeStatus hs = readHingeSensor(); |
550 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 563 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
551 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 564 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
552 | else dir = CW; | 565 | else dir = CW; |
553 | } | 566 | } |
554 | break; | 567 | break; |
555 | case Model_Zaurus_SL6000: | 568 | case Model_Zaurus_SL6000: |
556 | case Model_Zaurus_SLA300: | 569 | case Model_Zaurus_SLA300: |
557 | case Model_Zaurus_SLB600: | 570 | case Model_Zaurus_SLB600: |
558 | case Model_Zaurus_SL5500: | 571 | case Model_Zaurus_SL5500: |
559 | case Model_Zaurus_SL5000: | 572 | case Model_Zaurus_SL5000: |
560 | default: dir = d->m_direction; | 573 | default: dir = d->m_direction; |
561 | break; | 574 | break; |
562 | } | 575 | } |
563 | return dir; | 576 | return dir; |
564 | 577 | ||
565 | } | 578 | } |
566 | 579 | ||
567 | bool Zaurus::hasHingeSensor() const | 580 | bool Zaurus::hasHingeSensor() const |
568 | { | 581 | { |
569 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; | 582 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; |
570 | } | 583 | } |
571 | 584 | ||
572 | OHingeStatus Zaurus::readHingeSensor() const | 585 | OHingeStatus Zaurus::readHingeSensor() const |
573 | { | 586 | { |
574 | if (m_embedix) | 587 | if (m_embedix) |
575 | { | 588 | { |
576 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 589 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |