summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/device.pro2
-rw-r--r--libopie2/opiecore/device/odevice.cpp14
-rw-r--r--libopie2/opiecore/device/odevice_abstractmobiledevice.cpp119
-rw-r--r--libopie2/opiecore/device/odevice_abstractmobiledevice.h64
-rw-r--r--libopie2/opiecore/device/odevice_beagle.h4
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.h4
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp21
-rw-r--r--libopie2/opiecore/device/odevice_jornada.h5
-rw-r--r--libopie2/opiecore/device/odevice_ramses.h2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h6
-rw-r--r--libopie2/opiecore/device/odevice_yopy.h4
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp36
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h5
14 files changed, 204 insertions, 84 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro
index 9a409e1..08bd4e1 100644
--- a/libopie2/opiecore/device/device.pro
+++ b/libopie2/opiecore/device/device.pro
@@ -2,2 +2,3 @@ HEADERS += device/odevice.h \
2 device/odevicebutton.h \ 2 device/odevicebutton.h \
3 device/odevice_abstractmobiledevice.h \
3 device/odevice_beagle.h \ 4 device/odevice_beagle.h \
@@ -13,2 +14,3 @@ SOURCES += device/odevice.cpp \
13 device/odevicebutton.cpp \ 14 device/odevicebutton.cpp \
15 device/odevice_abstractmobiledevice.cpp \
14 device/odevice_beagle.cpp \ 16 device/odevice_beagle.cpp \
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 2c5190c..ed705a6 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -256,6 +256,2 @@ ODevice::~ODevice()
256 256
257//#include <linux/apm_bios.h>
258
259#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
260
261/** 257/**
@@ -276,12 +272,2 @@ bool ODevice::suspend()
276 272
277//#include <linux/fb.h> better not rely on kernel headers in userspace ...
278
279#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
280
281/* VESA Blanking Levels */
282#define VESA_NO_BLANKING 0
283#define VESA_VSYNC_SUSPEND 1
284#define VESA_HSYNC_SUSPEND 2
285#define VESA_POWERDOWN 3
286
287/** 273/**
diff --git a/libopie2/opiecore/device/odevice_abstractmobiledevice.cpp b/libopie2/opiecore/device/odevice_abstractmobiledevice.cpp
new file mode 100644
index 0000000..f3f6af5
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_abstractmobiledevice.cpp
@@ -0,0 +1,119 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) 2004, 2005 Holger Hans Peter Freyther <freyther@handhelds.org>
4 Copyright (C) 2004, 2005 Michael 'mickey' Lauer <mickeyl@handhelds.org>
5 Copyright (C) 2002, 2003 Robert Griebl <sandman@handhelds.org>
6
7
8 =.
9 .=l.
10           .>+-=
11 _;:,     .>    :=|. This program is free software; you can
12.> <`_,   >  .   <= redistribute it and/or modify it under
13:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
14.="- .-=="i,     .._ License as published by the Free Software
15 - .   .-<_>     .<> Foundation; either version 2 of the License,
16     ._= =}       : or (at your option) any later version.
17    .%`+i>       _;_.
18    .i_,=:_.      -<s. This program is distributed in the hope that
19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
20    : ..    .:,     . . . without even the implied warranty of
21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
23..}^=.=       =       ; Library General Public License for more
24++=   -.     .`     .: details.
25 :     =  ...= . :.=-
26 -.   .:....=;==+<; You should have received a copy of the GNU
27  -_. . .   )=.  = Library General Public License along with
28    --        :-=` this library; see the file COPYING.LIB.
29 If not, write to the Free Software Foundation,
30 Inc., 59 Temple Place - Suite 330,
31 Boston, MA 02111-1307, USA.
32*/
33
34#include "odevice_abstractmobiledevice.h"
35
36#include <sys/time.h>
37#include <sys/ioctl.h>
38
39#include <time.h>
40#include <fcntl.h>
41#include <unistd.h>
42#include <stdlib.h>
43
44namespace Opie {
45namespace Core {
46OAbstractMobileDevice::OAbstractMobileDevice()
47 : m_timeOut( 1500 )
48{}
49
50/**
51 * @short Time to wait for the asynchronos APM implementation to suspend
52 *
53 * Milli Seconds to wait before returning from the suspend method.
54 * This is needed due asynchrnonus implementations of the APM bios.
55 *
56 */
57void OAbstractMobileDevice::setAPMTimeOut( int time ) {
58 m_timeOut = time;
59}
60
61
62bool OAbstractMobileDevice::suspend() {
63 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
64 return false;
65
66 bool res = false;
67 ODevice::sendSuspendmsg();
68
69 struct timeval tvs, tvn;
70 ::gettimeofday ( &tvs, 0 );
71
72 ::sync(); // flush fs caches
73 res = ( ::system ( "apm --suspend" ) == 0 );
74
75 // This is needed because some apm implementations are asynchronous and we
76 // can not be sure when exactly the device is really suspended
77 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
78
79 if ( res ) {
80 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
81 ::usleep ( 200 * 1000 );
82 ::gettimeofday ( &tvn, 0 );
83 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut );
84 }
85
86 return res;
87}
88
89//#include <linux/fb.h> better not rely on kernel headers in userspace ...
90
91// _IO and friends are only defined in kernel headers ...
92#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
93#define OD_IO(type,number) OD_IOC(0,type,number,0)
94
95#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
96
97/* VESA Blanking Levels */
98#define VESA_NO_BLANKING 0
99#define VESA_VSYNC_SUSPEND 1
100#define VESA_HSYNC_SUSPEND 2
101#define VESA_POWERDOWN 3
102
103bool OAbstractMobileDevice::setDisplayStatus ( bool on ) {
104 bool res = false;
105 int fd;
106
107#ifdef QT_QWS_DEVFS
108 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
109#else
110 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
111#endif
112 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
113 ::close ( fd );
114 }
115
116 return res;
117}
118}
119}
diff --git a/libopie2/opiecore/device/odevice_abstractmobiledevice.h b/libopie2/opiecore/device/odevice_abstractmobiledevice.h
new file mode 100644
index 0000000..9467e82
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_abstractmobiledevice.h
@@ -0,0 +1,64 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) 2004, 2005 Holger Hans Peter Freyther <freyther@handhelds.org>
4 Copyright (C) 2004, 2005 Michael 'mickey' Lauer <mickeyl@handhelds.org>
5
6
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31*/
32
33#ifndef OPIE_CORE_DEVICE_ABSTRACT_MOBILE_DEVICE
34#define OPIE_CORE_DEVICE_ABSTRACT_MOBILE_DEVICE
35
36#include "odevice.h"
37
38namespace Opie {
39namespace Core {
40/**
41 * @short Common Implementations for Linux Handheld Devices
42 *
43 * Abstract Class with implementation for suspending using
44 * asynchrnonus apm implementations and displaystatus using
45 * the Linux Frame Buffer API
46 *
47 */
48class OAbstractMobileDevice : public ODevice {
49 Q_OBJECT
50protected:
51 OAbstractMobileDevice();
52 void setAPMTimeOut( int time );
53public:
54 virtual bool suspend();
55 virtual bool setDisplayStatus(bool);
56
57private:
58 int m_timeOut;
59};
60}
61}
62
63
64#endif
diff --git a/libopie2/opiecore/device/odevice_beagle.h b/libopie2/opiecore/device/odevice_beagle.h
index 17b040c..697d689 100644
--- a/libopie2/opiecore/device/odevice_beagle.h
+++ b/libopie2/opiecore/device/odevice_beagle.h
@@ -32,3 +32,3 @@
32 32
33#include "odevice.h" 33#include "odevice_abstractmobiledevice.h"
34 34
@@ -37,3 +37,3 @@ namespace Core {
37namespace Internal { 37namespace Internal {
38class Beagle : public ODevice { 38class Beagle : public OAbstractMobileDevice {
39public: 39public:
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h
index b1dac74..1889467 100644
--- a/libopie2/opiecore/device/odevice_ipaq.h
+++ b/libopie2/opiecore/device/odevice_ipaq.h
@@ -32,3 +32,3 @@
32 32
33#include "odevice.h" 33#include "odevice_abstractmobiledevice.h"
34 34
@@ -41,3 +41,3 @@ namespace Internal {
41 41
42class iPAQ : public ODevice, public QWSServer::KeyboardFilter 42class iPAQ : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
43{ 43{
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index 8141f1c..5f95e42 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -172,23 +172,2 @@ bool Jornada::setDisplayBrightness( int bright )
172 172
173bool Jornada::suspend( )
174{
175 qDebug("ODevice::suspend");
176 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
177 return false;
178
179 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
180 return false;
181
182 bool res = false;
183 ODevice::sendSuspendmsg();
184
185 struct timeval tvs;
186 ::gettimeofday ( &tvs, 0 );
187
188 ::sync(); // flush fs caches
189 res = ( ::system ( "apm --suspend" ) == 0 );
190
191 return res;
192}
193
194bool Jornada::setDisplayStatus ( bool on ) 173bool Jornada::setDisplayStatus ( bool on )
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h
index b17fa8b..480efff 100644
--- a/libopie2/opiecore/device/odevice_jornada.h
+++ b/libopie2/opiecore/device/odevice_jornada.h
@@ -32,3 +32,3 @@
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
@@ -37,3 +37,3 @@ namespace Core {
37namespace Internal { 37namespace Internal {
38class Jornada : public ODevice 38class Jornada : public OAbstractMobileDevice
39{ 39{
@@ -45,3 +45,2 @@ class Jornada : public ODevice
45 public: 45 public:
46 virtual bool suspend ( );
47 virtual bool setDisplayBrightness ( int b ); 46 virtual bool setDisplayBrightness ( int b );
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h
index bbd3862..50963dc 100644
--- a/libopie2/opiecore/device/odevice_ramses.h
+++ b/libopie2/opiecore/device/odevice_ramses.h
@@ -32,3 +32,3 @@
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34/* QT */ 34/* QT */
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index d6c2c80..550da5e 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -334,3 +334,3 @@ bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
334 334
335 bool res = ODevice::suspend(); 335 bool res = OAbstractMobileDevice::suspend();
336 336
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index 41b94d1..1276603 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -32,3 +32,3 @@
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
@@ -41,4 +41,4 @@ namespace Internal {
41 41
42class SIMpad : public ODevice 42class SIMpad : public OAbstractMobileDevice
43{ 43{
44 protected: 44 protected:
diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h
index f6bf061..02a19c9 100644
--- a/libopie2/opiecore/device/odevice_yopy.h
+++ b/libopie2/opiecore/device/odevice_yopy.h
@@ -32,3 +32,3 @@ _;:,     .>    :=|. This program is free software; you can
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
@@ -37,3 +37,3 @@ namespace Core {
37namespace Internal { 37namespace Internal {
38class Yopy : public ODevice 38class Yopy : public OAbstractMobileDevice
39{ 39{
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
@@ -134,2 +134,6 @@ 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 -
@@ -484,34 +488,2 @@ bool Zaurus::setDisplayStatus( bool on )
484 488
485bool 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
517Transformation Zaurus::rotation() const 489Transformation Zaurus::rotation() const
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index 80593ce..6e6ca46 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -32,3 +32,3 @@
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
@@ -93,3 +93,3 @@ namespace Internal {
93 93
94class Zaurus : public ODevice 94class Zaurus : public OAbstractMobileDevice
95{ 95{
@@ -116,3 +116,2 @@ class Zaurus : public ODevice
116 116
117 virtual bool suspend();
118 virtual Transformation rotation() const; 117 virtual Transformation rotation() const;