summaryrefslogtreecommitdiff
authorzecke <zecke>2005-02-17 23:52:46 (UTC)
committer zecke <zecke>2005-02-17 23:52:46 (UTC)
commit9bf35a9978c8a9e8b9c2100abf9137ffefc73e17 (patch) (unidiff)
treef251c1697f2ed091d8f55eca7aa1b8f4a85c7889
parent87cbafeb59d0505b631be811bd96fb1d0b1df1f7 (diff)
downloadopie-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 (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
@@ -1,21 +1,23 @@
1HEADERS += device/odevice.h \ 1HEADERS += 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 \
4 device/odevice_ipaq.h \ 5 device/odevice_ipaq.h \
5 device/odevice_jornada.h \ 6 device/odevice_jornada.h \
6 device/odevice_ramses.h \ 7 device/odevice_ramses.h \
7 device/odevice_simpad.h \ 8 device/odevice_simpad.h \
8 device/odevice_zaurus.h \ 9 device/odevice_zaurus.h \
9 device/odevice_genuineintel.h \ 10 device/odevice_genuineintel.h \
10 device/odevice_yopy.h 11 device/odevice_yopy.h
11 12
12SOURCES += device/odevice.cpp \ 13SOURCES += 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 \
15 device/odevice_ipaq.cpp \ 17 device/odevice_ipaq.cpp \
16 device/odevice_jornada.cpp\ 18 device/odevice_jornada.cpp\
17 device/odevice_ramses.cpp \ 19 device/odevice_ramses.cpp \
18 device/odevice_simpad.cpp \ 20 device/odevice_simpad.cpp \
19 device/odevice_zaurus.cpp \ 21 device/odevice_zaurus.cpp \
20 device/odevice_genuineintel.cpp \ 22 device/odevice_genuineintel.cpp \
21 device/odevice_yopy.cpp 23 device/odevice_yopy.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
@@ -249,46 +249,32 @@ void ODevice::initButtons()
249ODevice::~ODevice() 249ODevice::~ODevice()
250{ 250{
251// we leak m_devicebuttons and m_cpu_frequency 251// we leak m_devicebuttons and m_cpu_frequency
252// but it's a singleton and it is not so importantant 252// but it's a singleton and it is not so importantant
253// -zecke 253// -zecke
254 delete d; 254 delete d;
255} 255}
256 256
257//#include <linux/apm_bios.h>
258
259#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
260
261/** 257/**
262* This method will try to suspend the device 258* This method will try to suspend the device
263* It only works if the user is the QWS Server and the apm application 259* It only works if the user is the QWS Server and the apm application
264* is installed. 260* is installed.
265* It tries to suspend and then waits some time cause some distributions 261* It tries to suspend and then waits some time cause some distributions
266* do have asynchronus apm implementations. 262* do have asynchronus apm implementations.
267* This method will either fail and return false or it'll suspend the 263* This method will either fail and return false or it'll suspend the
268* device and return once the device got woken up 264* device and return once the device got woken up
269* 265*
270* @return if the device got suspended 266* @return if the device got suspended
271*/ 267*/
272bool ODevice::suspend() 268bool ODevice::suspend()
273{ 269{
274 return false; // default implementation == unknown device or qvfb 270 return false; // default implementation == unknown device or qvfb
275} 271}
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/**
288* This sets the display on or off 274* This sets the display on or off
289*/ 275*/
290bool ODevice::setDisplayStatus( bool on ) 276bool ODevice::setDisplayStatus( bool on )
291{ 277{
292 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); 278 qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on );
293 return false; // don't do anything for unknown models 279 return false; // don't do anything for unknown models
294} 280}
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
@@ -25,22 +25,22 @@
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef OPIE_CORE_DEVICE_BEAGLE_H 30#ifndef OPIE_CORE_DEVICE_BEAGLE_H
31#define OPIE_CORE_DEVICE_BEAGLE_H 31#define OPIE_CORE_DEVICE_BEAGLE_H
32 32
33#include "odevice.h" 33#include "odevice_abstractmobiledevice.h"
34 34
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Internal { 37namespace Internal {
38class Beagle : public ODevice { 38class Beagle : public OAbstractMobileDevice {
39public: 39public:
40 Beagle(); 40 Beagle();
41 ~Beagle(); 41 ~Beagle();
42 42
43//@{ 43//@{
44 void init( const QString& init ); 44 void init( const QString& init );
45 void initButtons(); 45 void initButtons();
46//@} 46//@}
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
@@ -25,26 +25,26 @@
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_IPAQ 30#ifndef ODEVICE_IPAQ
31#define ODEVICE_IPAQ 31#define ODEVICE_IPAQ
32 32
33#include "odevice.h" 33#include "odevice_abstractmobiledevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class iPAQ : public ODevice, public QWSServer::KeyboardFilter 42class iPAQ : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
43{ 43{
44 44
45 protected: 45 protected:
46 virtual void init(const QString&); 46 virtual void init(const QString&);
47 virtual void initButtons(); 47 virtual void initButtons();
48 48
49 public: 49 public:
50 virtual bool setDisplayBrightness( int b ); 50 virtual bool setDisplayBrightness( int b );
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
@@ -165,37 +165,16 @@ bool Jornada::setDisplayBrightness( int bright )
165 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright ); 165 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright );
166 166
167 res = ( ::system( (const char*) cmdline ) == 0 ); 167 res = ( ::system( (const char*) cmdline ) == 0 );
168 168
169 return res; 169 return res;
170} 170}
171 171
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 )
195{ 174{
196 bool res = false; 175 bool res = false;
197 176
198 QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); 177 QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
199 178
200 res = ( ::system( (const char*) cmdline ) == 0 ); 179 res = ( ::system( (const char*) cmdline ) == 0 );
201 180
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
@@ -25,30 +25,29 @@
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_JORNADA 30#ifndef ODEVICE_JORNADA
31#define ODEVICE_JORNADA 31#define ODEVICE_JORNADA
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Internal { 37namespace Internal {
38class Jornada : public ODevice 38class Jornada : public OAbstractMobileDevice
39{ 39{
40 40
41 protected: 41 protected:
42 virtual void init(const QString&); 42 virtual void init(const QString&);
43 virtual void initButtons(); 43 virtual void initButtons();
44 44
45 public: 45 public:
46 virtual bool suspend ( );
47 virtual bool setDisplayBrightness ( int b ); 46 virtual bool setDisplayBrightness ( int b );
48 virtual bool setDisplayStatus ( bool on); 47 virtual bool setDisplayStatus ( bool on);
49 virtual int displayBrightnessResolution() const; 48 virtual int displayBrightnessResolution() const;
50}; 49};
51 50
52struct j_button { 51struct j_button {
53 uint model; 52 uint model;
54 Qt::Key code; 53 Qt::Key code;
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
@@ -25,17 +25,17 @@
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_RAMSES 30#ifndef ODEVICE_RAMSES
31#define ODEVICE_RAMSES 31#define ODEVICE_RAMSES
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34/* QT */ 34/* QT */
35#include <qwindowsystem_qws.h> 35#include <qwindowsystem_qws.h>
36 36
37 37
38#ifndef OD_IOC 38#ifndef OD_IOC
39#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 39#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
40#define OD_IO(type,number) OD_IOC(0,type,number,0) 40#define OD_IO(type,number) OD_IOC(0,type,number,0)
41#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 41#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
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
@@ -327,17 +327,17 @@ void SIMpad::playAlarmSound()
327} 327}
328 328
329 329
330bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 330bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
331{ 331{
332 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 332 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
333 return false; 333 return false;
334 334
335 bool res = ODevice::suspend(); 335 bool res = OAbstractMobileDevice::suspend();
336 336
337 /* 337 /*
338 * restore the screen content if we really 338 * restore the screen content if we really
339 * supended the device 339 * supended the device
340 */ 340 */
341 if ( res ) 341 if ( res )
342 updateAllWidgets(); 342 updateAllWidgets();
343 343
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
@@ -25,27 +25,27 @@
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_SIMPAD 30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD 31#define ODEVICE_SIMPAD
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class SIMpad : public ODevice 42class SIMpad : public OAbstractMobileDevice
43{ 43{
44 protected: 44 protected:
45 virtual void init(const QString&); 45 virtual void init(const QString&);
46 virtual void initButtons(); 46 virtual void initButtons();
47 47
48 public: 48 public:
49 virtual bool suspend(); 49 virtual bool suspend();
50 50
51 virtual bool setDisplayStatus( bool on ); 51 virtual bool setDisplayStatus( bool on );
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
@@ -25,22 +25,22 @@ _;:,     .>    :=|. This program is free software; you can
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_YOPY 30#ifndef ODEVICE_YOPY
31#define ODEVICE_YOPY 31#define ODEVICE_YOPY
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Internal { 37namespace Internal {
38class Yopy : public ODevice 38class Yopy : public OAbstractMobileDevice
39{ 39{
40 protected: 40 protected:
41 41
42 virtual void init(const QString&); 42 virtual void init(const QString&);
43 virtual void initButtons(); 43 virtual void initButtons();
44 44
45 public: 45 public:
46 virtual bool suspend(); 46 virtual bool suspend();
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
@@ -127,16 +127,20 @@ struct z_button z_buttons_c700 [] = {
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
133void Zaurus::init(const QString& cpu_info) 133void 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;
@@ -477,48 +481,16 @@ bool Zaurus::setDisplayStatus( bool on )
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
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
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:
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
@@ -25,17 +25,17 @@
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_ZAURUS 30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS 31#define ODEVICE_ZAURUS
32 32
33#include <opie2/odevice.h> 33#include "odevice_abstractmobiledevice.h"
34 34
35#ifndef ARRAY_SIZE 35#ifndef ARRAY_SIZE
36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
37#endif 37#endif
38 38
39// _IO and friends are only defined in kernel headers ... 39// _IO and friends are only defined in kernel headers ...
40#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 40#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
41#define OD_IO(type,number) OD_IOC(0,type,number,0) 41#define OD_IO(type,number) OD_IOC(0,type,number,0)
@@ -86,17 +86,17 @@
86// Vesa Standard 86// Vesa Standard
87 #define FB_BLANK_UNBLANK 0 87 #define FB_BLANK_UNBLANK 0
88 #define FB_BLANK_POWERDOWN 4 88 #define FB_BLANK_POWERDOWN 4
89 89
90namespace Opie { 90namespace Opie {
91namespace Core { 91namespace Core {
92namespace Internal { 92namespace Internal {
93 93
94class Zaurus : public ODevice 94class Zaurus : public OAbstractMobileDevice
95{ 95{
96 protected: 96 protected:
97 virtual void init(const QString&); 97 virtual void init(const QString&);
98 virtual void initButtons(); 98 virtual void initButtons();
99 99
100 public: 100 public:
101 virtual bool setDisplayBrightness( int b ); 101 virtual bool setDisplayBrightness( int b );
102 virtual bool setDisplayStatus( bool on ); 102 virtual bool setDisplayStatus( bool on );
@@ -109,17 +109,16 @@ class Zaurus : public ODevice
109 virtual QValueList <OLed> ledList() const; 109 virtual QValueList <OLed> ledList() const;
110 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 110 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
111 virtual OLedState ledState( OLed led ) const; 111 virtual OLedState ledState( OLed led ) const;
112 virtual bool setLedState( OLed led, OLedState st ); 112 virtual bool setLedState( OLed led, OLedState st );
113 113
114 virtual bool hasHingeSensor() const; 114 virtual bool hasHingeSensor() const;
115 virtual OHingeStatus readHingeSensor() const; 115 virtual OHingeStatus readHingeSensor() const;
116 116
117 virtual bool suspend();
118 virtual Transformation rotation() const; 117 virtual Transformation rotation() const;
119 virtual ODirection direction() const; 118 virtual ODirection direction() const;
120 119
121 protected: 120 protected:
122 virtual void buzzer( int snd ); 121 virtual void buzzer( int snd );
123 122
124 OLedState m_leds[1]; 123 OLedState m_leds[1];
125 bool m_embedix; 124 bool m_embedix;