author | zecke <zecke> | 2005-02-17 23:52:46 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-17 23:52:46 (UTC) |
commit | 9bf35a9978c8a9e8b9c2100abf9137ffefc73e17 (patch) (unidiff) | |
tree | f251c1697f2ed091d8f55eca7aa1b8f4a85c7889 /libopie2/opiecore/device/odevice_zaurus.cpp | |
parent | 87cbafeb59d0505b631be811bd96fb1d0b1df1f7 (diff) | |
download | opie-9bf35a9978c8a9e8b9c2100abf9137ffefc73e17.zip opie-9bf35a9978c8a9e8b9c2100abf9137ffefc73e17.tar.gz opie-9bf35a9978c8a9e8b9c2100abf9137ffefc73e17.tar.bz2 |
Add OAbstractMobileDevice with implementations for suspend and setDisplayStatus
Switch our implementations over to this partial implementation of ODevice
Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 82e127e..67dfa41 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -123,24 +123,28 @@ struct z_button z_buttons_c700 [] = { | |||
123 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 123 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
124 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) | 124 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) |
125 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) | 125 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) |
126 | // | 126 | // |
127 | // Only question right now is: Do we really need to do it? Because as soon | 127 | // Only question right now is: Do we really need to do it? Because as soon |
128 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 128 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
129 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 129 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
130 | // | 130 | // |
131 | // Comments? - mickeyl. | 131 | // Comments? - mickeyl. |
132 | 132 | ||
133 | void Zaurus::init(const QString& cpu_info) | 133 | void Zaurus::init(const QString& cpu_info) |
134 | { | 134 | { |
135 | // Set the time to wait until the system is realy suspended | ||
136 | // the delta between apm --suspend and sleeping | ||
137 | setAPMTimeOut( 15000 ); | ||
138 | |||
135 | // generic distribution code already scanned /etc/issue at that point - | 139 | // generic distribution code already scanned /etc/issue at that point - |
136 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 140 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
137 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 141 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
138 | { | 142 | { |
139 | d->m_vendorstr = "Sharp"; | 143 | d->m_vendorstr = "Sharp"; |
140 | d->m_vendor = Vendor_Sharp; | 144 | d->m_vendor = Vendor_Sharp; |
141 | d->m_systemstr = "Zaurus"; | 145 | d->m_systemstr = "Zaurus"; |
142 | d->m_system = System_Zaurus; | 146 | d->m_system = System_Zaurus; |
143 | m_embedix = true; | 147 | m_embedix = true; |
144 | } | 148 | } |
145 | else | 149 | else |
146 | { | 150 | { |
@@ -473,56 +477,24 @@ bool Zaurus::setDisplayStatus( bool on ) | |||
473 | if ( fd ) | 477 | if ( fd ) |
474 | { | 478 | { |
475 | char buf[10]; | 479 | char buf[10]; |
476 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 480 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
477 | buf[1] = '\0'; | 481 | buf[1] = '\0'; |
478 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 482 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
479 | ::close( fd ); | 483 | ::close( fd ); |
480 | } | 484 | } |
481 | } | 485 | } |
482 | return res; | 486 | return res; |
483 | } | 487 | } |
484 | 488 | ||
485 | bool Zaurus::suspend() | ||
486 | { | ||
487 | qDebug("ODevice::suspend"); | ||
488 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | ||
489 | return false; | ||
490 | |||
491 | if ( d->m_model == Model_Unknown ) // better don't suspend on unknown devices | ||
492 | return false; | ||
493 | |||
494 | bool res = false; | ||
495 | ODevice::sendSuspendmsg(); | ||
496 | |||
497 | struct timeval tvs, tvn; | ||
498 | ::gettimeofday ( &tvs, 0 ); | ||
499 | |||
500 | ::sync(); // flush fs caches | ||
501 | res = ( ::system ( "apm --suspend" ) == 0 ); | ||
502 | |||
503 | // This is needed because the apm implementation is asynchronous and we | ||
504 | // can not be sure when exactly the device is really suspended | ||
505 | if ( res ) { | ||
506 | do { // Yes, wait 15 seconds. This APM sucks big time. | ||
507 | ::usleep ( 200 * 1000 ); | ||
508 | ::gettimeofday ( &tvn, 0 ); | ||
509 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | ||
510 | } | ||
511 | |||
512 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | ||
513 | return res; | ||
514 | } | ||
515 | |||
516 | |||
517 | Transformation Zaurus::rotation() const | 489 | Transformation Zaurus::rotation() const |
518 | { | 490 | { |
519 | qDebug( "Zaurus::rotation()" ); | 491 | qDebug( "Zaurus::rotation()" ); |
520 | Transformation rot; | 492 | Transformation rot; |
521 | 493 | ||
522 | switch ( d->m_model ) { | 494 | switch ( d->m_model ) { |
523 | case Model_Zaurus_SLC3000: // fallthrough | 495 | case Model_Zaurus_SLC3000: // fallthrough |
524 | case Model_Zaurus_SLC7x0: | 496 | case Model_Zaurus_SLC7x0: |
525 | { | 497 | { |
526 | OHingeStatus hs = readHingeSensor(); | 498 | OHingeStatus hs = readHingeSensor(); |
527 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | 499 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); |
528 | 500 | ||