summaryrefslogtreecommitdiff
Side-by-side diff
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,19 +1,21 @@
HEADERS += device/odevice.h \
device/odevicebutton.h \
+ device/odevice_abstractmobiledevice.h \
device/odevice_beagle.h \
device/odevice_ipaq.h \
device/odevice_jornada.h \
device/odevice_ramses.h \
device/odevice_simpad.h \
device/odevice_zaurus.h \
device/odevice_genuineintel.h \
device/odevice_yopy.h
SOURCES += device/odevice.cpp \
device/odevicebutton.cpp \
+ device/odevice_abstractmobiledevice.cpp \
device/odevice_beagle.cpp \
device/odevice_ipaq.cpp \
device/odevice_jornada.cpp\
device/odevice_ramses.cpp \
device/odevice_simpad.cpp \
device/odevice_zaurus.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
@@ -251,16 +251,12 @@ ODevice::~ODevice()
// we leak m_devicebuttons and m_cpu_frequency
// but it's a singleton and it is not so importantant
// -zecke
delete d;
}
-//#include <linux/apm_bios.h>
-
-#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
-
/**
* This method will try to suspend the device
* It only works if the user is the QWS Server and the apm application
* is installed.
* It tries to suspend and then waits some time cause some distributions
* do have asynchronus apm implementations.
@@ -271,22 +267,12 @@ ODevice::~ODevice()
*/
bool ODevice::suspend()
{
return false; // default implementation == unknown device or qvfb
}
-//#include <linux/fb.h> better not rely on kernel headers in userspace ...
-
-#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
-
-/* VESA Blanking Levels */
-#define VESA_NO_BLANKING 0
-#define VESA_VSYNC_SUSPEND 1
-#define VESA_HSYNC_SUSPEND 2
-#define VESA_POWERDOWN 3
-
/**
* This sets the display on or off
*/
bool ODevice::setDisplayStatus( bool on )
{
qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on );
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 @@
+/*
+                 This file is part of the Opie Project
+              Copyright (C) 2004, 2005 Holger Hans Peter Freyther <freyther@handhelds.org>
+ Copyright (C) 2004, 2005 Michael 'mickey' Lauer <mickeyl@handhelds.org>
+ Copyright (C) 2002, 2003 Robert Griebl <sandman@handhelds.org>
+
+
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "odevice_abstractmobiledevice.h"
+
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#include <time.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+namespace Opie {
+namespace Core {
+OAbstractMobileDevice::OAbstractMobileDevice()
+ : m_timeOut( 1500 )
+{}
+
+/**
+ * @short Time to wait for the asynchronos APM implementation to suspend
+ *
+ * Milli Seconds to wait before returning from the suspend method.
+ * This is needed due asynchrnonus implementations of the APM bios.
+ *
+ */
+void OAbstractMobileDevice::setAPMTimeOut( int time ) {
+ m_timeOut = time;
+}
+
+
+bool OAbstractMobileDevice::suspend() {
+ if ( !isQWS( ) ) // only qwsserver is allowed to suspend
+ return false;
+
+ bool res = false;
+ ODevice::sendSuspendmsg();
+
+ struct timeval tvs, tvn;
+ ::gettimeofday ( &tvs, 0 );
+
+ ::sync(); // flush fs caches
+ res = ( ::system ( "apm --suspend" ) == 0 );
+
+ // This is needed because some apm implementations are asynchronous and we
+ // can not be sure when exactly the device is really suspended
+ // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
+
+ if ( res ) {
+ do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
+ ::usleep ( 200 * 1000 );
+ ::gettimeofday ( &tvn, 0 );
+ } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut );
+ }
+
+ return res;
+}
+
+//#include <linux/fb.h> better not rely on kernel headers in userspace ...
+
+// _IO and friends are only defined in kernel headers ...
+#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
+#define OD_IO(type,number) OD_IOC(0,type,number,0)
+
+#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
+
+/* VESA Blanking Levels */
+#define VESA_NO_BLANKING 0
+#define VESA_VSYNC_SUSPEND 1
+#define VESA_HSYNC_SUSPEND 2
+#define VESA_POWERDOWN 3
+
+bool OAbstractMobileDevice::setDisplayStatus ( bool on ) {
+ bool res = false;
+ int fd;
+
+#ifdef QT_QWS_DEVFS
+ if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
+#else
+ if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
+#endif
+ res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
+ ::close ( fd );
+ }
+
+ return res;
+}
+}
+}
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 @@
+/*
+                 This file is part of the Opie Project
+              Copyright (C) 2004, 2005 Holger Hans Peter Freyther <freyther@handhelds.org>
+ Copyright (C) 2004, 2005 Michael 'mickey' Lauer <mickeyl@handhelds.org>
+
+
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef OPIE_CORE_DEVICE_ABSTRACT_MOBILE_DEVICE
+#define OPIE_CORE_DEVICE_ABSTRACT_MOBILE_DEVICE
+
+#include "odevice.h"
+
+namespace Opie {
+namespace Core {
+/**
+ * @short Common Implementations for Linux Handheld Devices
+ *
+ * Abstract Class with implementation for suspending using
+ * asynchrnonus apm implementations and displaystatus using
+ * the Linux Frame Buffer API
+ *
+ */
+class OAbstractMobileDevice : public ODevice {
+ Q_OBJECT
+protected:
+ OAbstractMobileDevice();
+ void setAPMTimeOut( int time );
+public:
+ virtual bool suspend();
+ virtual bool setDisplayStatus(bool);
+
+private:
+ int m_timeOut;
+};
+}
+}
+
+
+#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
@@ -27,18 +27,18 @@
Boston, MA 02111-1307, USA.
*/
#ifndef OPIE_CORE_DEVICE_BEAGLE_H
#define OPIE_CORE_DEVICE_BEAGLE_H
-#include "odevice.h"
+#include "odevice_abstractmobiledevice.h"
namespace Opie {
namespace Core {
namespace Internal {
-class Beagle : public ODevice {
+class Beagle : public OAbstractMobileDevice {
public:
Beagle();
~Beagle();
//@{
void init( const QString& init );
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
@@ -27,22 +27,22 @@
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_IPAQ
#define ODEVICE_IPAQ
-#include "odevice.h"
+#include "odevice_abstractmobiledevice.h"
/* QT */
#include <qwindowsystem_qws.h>
namespace Opie {
namespace Core {
namespace Internal {
-class iPAQ : public ODevice, public QWSServer::KeyboardFilter
+class iPAQ : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
{
protected:
virtual void init(const QString&);
virtual void initButtons();
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
@@ -167,33 +167,12 @@ bool Jornada::setDisplayBrightness( int bright )
res = ( ::system( (const char*) cmdline ) == 0 );
return res;
}
-bool Jornada::suspend( )
-{
- qDebug("ODevice::suspend");
- if ( !isQWS( ) ) // only qwsserver is allowed to suspend
- return false;
-
- if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
- return false;
-
- bool res = false;
- ODevice::sendSuspendmsg();
-
- struct timeval tvs;
- ::gettimeofday ( &tvs, 0 );
-
- ::sync(); // flush fs caches
- res = ( ::system ( "apm --suspend" ) == 0 );
-
- return res;
-}
-
bool Jornada::setDisplayStatus ( bool on )
{
bool res = false;
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" );
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
@@ -27,26 +27,25 @@
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_JORNADA
#define ODEVICE_JORNADA
-#include <opie2/odevice.h>
+#include "odevice_abstractmobiledevice.h"
namespace Opie {
namespace Core {
namespace Internal {
-class Jornada : public ODevice
+class Jornada : public OAbstractMobileDevice
{
protected:
virtual void init(const QString&);
virtual void initButtons();
public:
- virtual bool suspend ( );
virtual bool setDisplayBrightness ( int b );
virtual bool setDisplayStatus ( bool on);
virtual int displayBrightnessResolution() const;
};
struct j_button {
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
@@ -27,13 +27,13 @@
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_RAMSES
#define ODEVICE_RAMSES
-#include <opie2/odevice.h>
+#include "odevice_abstractmobiledevice.h"
/* QT */
#include <qwindowsystem_qws.h>
#ifndef OD_IOC
#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
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
@@ -329,13 +329,13 @@ void SIMpad::playAlarmSound()
bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
{
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
- bool res = ODevice::suspend();
+ bool res = OAbstractMobileDevice::suspend();
/*
* restore the screen content if we really
* supended the device
*/
if ( res )
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
@@ -27,23 +27,23 @@
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_SIMPAD
#define ODEVICE_SIMPAD
-#include <opie2/odevice.h>
+#include "odevice_abstractmobiledevice.h"
/* QT */
#include <qwindowsystem_qws.h>
namespace Opie {
namespace Core {
namespace Internal {
-class SIMpad : public ODevice
-{
+class SIMpad : public OAbstractMobileDevice
+{
protected:
virtual void init(const QString&);
virtual void initButtons();
public:
virtual bool suspend();
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
@@ -27,18 +27,18 @@ _;:,     .>    :=|. This program is free software; you can
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_YOPY
#define ODEVICE_YOPY
-#include <opie2/odevice.h>
+#include "odevice_abstractmobiledevice.h"
namespace Opie {
namespace Core {
namespace Internal {
-class Yopy : public ODevice
+class Yopy : public OAbstractMobileDevice
{
protected:
virtual void init(const QString&);
virtual void initButtons();
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
@@ -129,12 +129,16 @@ struct z_button z_buttons_c700 [] = {
// Zaurus models (concerning apm, backlight, buttons, etc.)
//
// Comments? - mickeyl.
void Zaurus::init(const QString& cpu_info)
{
+ // Set the time to wait until the system is realy suspended
+ // the delta between apm --suspend and sleeping
+ setAPMTimeOut( 15000 );
+
// generic distribution code already scanned /etc/issue at that point -
// embedix releases contain "Embedix <version> | Linux for Embedded Devices"
if ( d->m_sysverstr.contains( "embedix", false ) )
{
d->m_vendorstr = "Sharp";
d->m_vendor = Vendor_Sharp;
@@ -479,44 +483,12 @@ bool Zaurus::setDisplayStatus( bool on )
::close( fd );
}
}
return res;
}
-bool Zaurus::suspend()
-{
- qDebug("ODevice::suspend");
- if ( !isQWS( ) ) // only qwsserver is allowed to suspend
- return false;
-
- if ( d->m_model == Model_Unknown ) // better don't suspend on unknown devices
- return false;
-
- bool res = false;
- ODevice::sendSuspendmsg();
-
- struct timeval tvs, tvn;
- ::gettimeofday ( &tvs, 0 );
-
- ::sync(); // flush fs caches
- res = ( ::system ( "apm --suspend" ) == 0 );
-
- // This is needed because the apm implementation is asynchronous and we
- // can not be sure when exactly the device is really suspended
- if ( res ) {
- do { // Yes, wait 15 seconds. This APM sucks big time.
- ::usleep ( 200 * 1000 );
- ::gettimeofday ( &tvn, 0 );
- } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
- }
-
- QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
- return res;
-}
-
-
Transformation Zaurus::rotation() const
{
qDebug( "Zaurus::rotation()" );
Transformation rot;
switch ( d->m_model ) {
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
@@ -27,13 +27,13 @@
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_ZAURUS
#define ODEVICE_ZAURUS
-#include <opie2/odevice.h>
+#include "odevice_abstractmobiledevice.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
// _IO and friends are only defined in kernel headers ...
@@ -88,13 +88,13 @@
#define FB_BLANK_POWERDOWN 4
namespace Opie {
namespace Core {
namespace Internal {
-class Zaurus : public ODevice
+class Zaurus : public OAbstractMobileDevice
{
protected:
virtual void init(const QString&);
virtual void initButtons();
public:
@@ -111,13 +111,12 @@ class Zaurus : public ODevice
virtual OLedState ledState( OLed led ) const;
virtual bool setLedState( OLed led, OLedState st );
virtual bool hasHingeSensor() const;
virtual OHingeStatus readHingeSensor() const;
- virtual bool suspend();
virtual Transformation rotation() const;
virtual ODirection direction() const;
protected:
virtual void buzzer( int snd );