summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore/device') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/device.pro14
-rw-r--r--libopie2/opiecore/device/odevice.cpp4
-rw-r--r--libopie2/opiecore/device/odevice.h24
-rw-r--r--libopie2/opiecore/device/odevice_motorola_ezx.cpp325
-rw-r--r--libopie2/opiecore/device/odevice_motorola_ezx.h102
5 files changed, 452 insertions, 17 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro
index 0954733..b517032 100644
--- a/libopie2/opiecore/device/device.pro
+++ b/libopie2/opiecore/device/device.pro
@@ -1,7 +1,7 @@
HEADERS += device/odevice.h \
device/odevicebutton.h \
- device/odevice_abstractmobiledevice.h \
- device/odevice_beagle.h \
+ device/odevice_abstractmobiledevice.h \
+ device/odevice_beagle.h \
device/odevice_ipaq.h \
device/odevice_jornada.h \
device/odevice_ramses.h \
@@ -10,12 +10,13 @@ HEADERS += device/odevice.h \
device/odevice_genuineintel.h \
device/odevice_yopy.h \
device/odevice_mypal.h \
- device/odevice_htc.h
+ device/odevice_htc.h \
+ device/odevice_motorola_ezx.h
SOURCES += device/odevice.cpp \
device/odevicebutton.cpp \
- device/odevice_abstractmobiledevice.cpp \
- device/odevice_beagle.cpp \
+ device/odevice_abstractmobiledevice.cpp \
+ device/odevice_beagle.cpp \
device/odevice_ipaq.cpp \
device/odevice_jornada.cpp\
device/odevice_ramses.cpp \
@@ -24,5 +25,6 @@ SOURCES += device/odevice.cpp \
device/odevice_genuineintel.cpp \
device/odevice_yopy.cpp \
device/odevice_mypal.cpp \
- device/odevice_htc.cpp
+ device/odevice_htc.cpp \
+ device/odevice_motorola_ezx.cpp
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index c6e031f..8f5be8b 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,6 +1,6 @@
/*
                This file is part of the Opie Project
- =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
+ =. (C) 2002-2006 The Opie Team <opie-devel@handhelds.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
@@ -38,6 +38,7 @@
#include "odevice_zaurus.h"
#include "odevice_genuineintel.h"
#include "odevice_htc.h"
+#include "odevice_motorola_ezx.h"
/* QT */
#include <qapplication.h>
@@ -146,6 +147,7 @@ ODevice *ODevice::inst()
else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
else if ( line.contains( "HTC", false ) ) dev = new Internal::HTC();
+ else if ( line.contains( "Motorola", false ) ) dev = new Internal::Motorola_EZX();
else qWarning( "ODevice() - unknown hardware - using default." );
break;
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 2566979..9afb92d 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,6 +1,6 @@
/*
                This file is part of the Opie Project
-              Copyright (C) The Opie Team <opie-devel@handhelds.org>
+              (C) 2002-2006 The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
@@ -8,8 +8,8 @@
.> <`_,   >  .   <= 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.
+ - .   .-<_>     .<> Foundation; version 2 of the License.
+     ._= =}       :
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
@@ -124,7 +124,12 @@ enum OModel {
Model_HTC = ( 9 << 16 ),
Model_HTC_All = ( Model_HTC | 0xffff ),
- Model_HTC_Universal = ( Model_HTC | 0x0001 )
+ Model_HTC_Universal = ( Model_HTC | 0x0001 ),
+
+ Model_Motorola = ( 9 << 17 ),
+ Model_Motorola_All = ( Model_Motorola | 0xffff ),
+ Model_Motorola_EZX = ( Model_Motorola | 0x0001 ),
+
};
/**
@@ -141,7 +146,8 @@ enum OVendor {
Vendor_MasterIA,
Vendor_GenuineIntel,
Vendor_Asus,
- Vendor_HTC
+ Vendor_HTC,
+ Vendor_Motorola,
};
/**
@@ -155,7 +161,9 @@ enum OSystem {
System_OpenZaurus,
System_Linupy,
System_OpenEmbedded,
- System_PC
+ System_PC,
+ System_OpenEZX,
+ System_Angstrom,
};
typedef struct {
@@ -390,8 +398,4 @@ extern QCString makeChannel ( const char *str );
}
}
-
-
-
#endif
-
diff --git a/libopie2/opiecore/device/odevice_motorola_ezx.cpp b/libopie2/opiecore/device/odevice_motorola_ezx.cpp
new file mode 100644
index 0000000..69256dd
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_motorola_ezx.cpp
@@ -0,0 +1,325 @@
+/*
+                 This file is part of the Opie Project
+ =. (C) 2006 Michael 'Mickey' Lauer <mickey@Vanille.de>
+ .=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; version 2 of the License.
+     ._= =}       :
+    .%`+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_motorola_ezx.h"
+
+/* OPIE */
+#include <opie2/oinputsystem.h>
+#include <opie2/oresource.h>
+
+#include <qpe/config.h>
+#include <qpe/sound.h>
+
+/* QT */
+#include <qapplication.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qwindowsystem_qws.h>
+#include <qcopchannel_qws.h>
+
+/* STD */
+#include <assert.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <math.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <unistd.h>
+#ifndef QT_NO_SOUND
+#include <linux/soundcard.h>
+#endif
+
+using namespace Opie::Core;
+using namespace Opie::Core::Internal;
+
+struct ezx_button ezx_buttons [] = {
+ { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
+ "devicebuttons/z_calendar",
+ "datebook", "nextView()",
+ "today", "raise()" },
+ { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
+ "devicebuttons/z_contact",
+ "addressbook", "raise()",
+ "addressbook", "beamBusinessCard()" },
+ { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
+ "devicebuttons/z_home",
+ "QPE/Launcher", "home()",
+ "buttonsettings", "raise()" },
+ { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
+ "devicebuttons/z_menu",
+ "QPE/TaskBar", "toggleMenu()",
+ "QPE/TaskBar", "toggleStartMenu()" },
+ { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
+ "devicebuttons/z_mail",
+ "opiemail", "raise()",
+ "opiemail", "newMail()" },
+};
+
+void Motorola_EZX::init(const QString& cpu_info)
+{
+ qDebug( "Motorola_EZX::init()" );
+ // Set the time to wait until the system is really suspended
+ // the delta between apm --suspend and sleeping
+ setAPMTimeOut( 15000 );
+
+ d->m_vendorstr = "OpenEZX Team";
+ d->m_systemstr = "OpenEZX";
+ d->m_system = System_OpenEZX;
+ // sysver already gathered
+
+ // check the Motorola_EZX model
+ QString model;
+ int loc = cpu_info.find( ":" );
+ if ( loc != -1 )
+ model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
+ else
+ model = cpu_info;
+
+ if ( model == "Motorola Ezx Platform" ) {
+ d->m_model = Model_Motorola_EZX;
+ d->m_modelstr = "Motorola_EZX";
+ } else assert( 0 );
+
+ // set path to backlight device in kernel 2.6
+ m_backlightdev = "/sys/class/backlight/ezx-bl/";
+ d->m_rotation = Rot0;
+ //initHingeSensor();
+
+ // set default qte driver and led state
+ d->m_qteDriver = "Transformed";
+ m_leds[0] = Led_Off;
+
+ qDebug( "Motorola_EZX::init() - Using the 2.6 OpenEZX HAL on a %s", (const char*) d->m_modelstr );
+}
+
+void Motorola_EZX::initButtons()
+{
+ qDebug( "Motorola_EZX::initButtons()" );
+ if ( d->m_buttons )
+ return;
+
+ d->m_buttons = new QValueList <ODeviceButton>;
+
+ struct ezx_button * ezx_buttons;
+ int buttoncount;
+
+/*
+
+ switch ( d->m_model )
+ {
+ case Model_Motorola_EZX_SL6000:
+ pezx_buttons = ezx_buttons_6000;
+ buttoncount = ARRAY_SIZE(ezx_buttons_6000);
+ break;
+ case Model_Motorola_EZX_SLC3100: // fallthrough
+ case Model_Motorola_EZX_SLC3000: // fallthrough
+ case Model_Motorola_EZX_SLC1000: // fallthrough
+ case Model_Motorola_EZX_SLC7x0:
+ if ( isQWS( ) )
+ {
+ addPreHandler(this);
+ }
+ pezx_buttons = ezx_buttons_c700;
+ buttoncount = ARRAY_SIZE(ezx_buttons_c700);
+ break;
+ default:
+ pezx_buttons = ezx_buttons;
+ buttoncount = ARRAY_SIZE(ezx_buttons);
+ break;
+ }
+
+ for ( int i = 0; i < buttoncount; i++ ) {
+ struct ezx_button *zb = pezx_buttons + i;
+ ODeviceButton b;
+
+ b.setKeycode( zb->code );
+ b.setUserText( QObject::tr( "Button", zb->utext ));
+ b.setPixmap( OResource::loadPixmap( zb->pix ));
+ b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
+ b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
+ d->m_buttons->append( b );
+ }
+*/
+ reloadButtonMapping();
+}
+
+void Motorola_EZX::playAlarmSound()
+{
+#ifndef QT_NO_SOUND
+ static Sound snd ( "alarm" );
+ if(!snd.isFinished())
+ return;
+
+ changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
+ snd. play();
+#endif
+}
+
+QValueList <OLed> Motorola_EZX::ledList() const
+{
+ QValueList <OLed> vl;
+ vl << Led_Mail;
+ return vl;
+}
+
+QValueList <OLedState> Motorola_EZX::ledStateList( OLed l ) const
+{
+ QValueList <OLedState> vl;
+
+ if ( l == Led_Mail )
+ vl << Led_Off << Led_On << Led_BlinkSlow;
+ return vl;
+}
+
+OLedState Motorola_EZX::ledState( OLed which ) const
+{
+ if ( which == Led_Mail )
+ return m_leds [0];
+ else
+ return Led_Off;
+}
+
+bool Motorola_EZX::setLedState( OLed which, OLedState st )
+{
+ // Currently not supported
+ qDebug( "Motorola_EZX::setLedState: ODevice handling not yet implemented" );
+ return false;
+}
+
+int Motorola_EZX::displayBrightnessResolution() const
+{
+ // Currently not supported
+ qDebug( "Motorola_EZX::displayBrightnessResolution: ODevice handling not yet implemented" );
+ return 100;
+
+#if 0
+ int res = 1;
+ if (m_embedix)
+ {
+ int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
+ if ( fd )
+ {
+ int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
+ ::close( fd );
+ return value ? value : res;
+ }
+ }
+ else
+ {
+ int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
+ if ( fd )
+ {
+ char buf[100];
+ if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
+ ::close( fd );
+ }
+ }
+ return res;
+#endif
+}
+
+bool Motorola_EZX::setDisplayBrightness( int bright )
+{
+ qDebug( "Motorola_EZX::setDisplayBrightness( %d )", bright );
+ return false;
+
+#if 0
+ bool res = false;
+
+ if ( bright > 255 ) bright = 255;
+ if ( bright < 0 ) bright = 0;
+
+ int numberOfSteps = displayBrightnessResolution();
+ int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
+
+ if ( m_embedix )
+ {
+ int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
+ if ( fd )
+ {
+ res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
+ ::close( fd );
+ }
+ }
+ else
+ {
+ int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
+ if ( fd )
+ {
+ char buf[100];
+ int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
+ res = ( ::write( fd, &buf[0], len ) == 0 );
+ ::close( fd );
+ }
+ }
+ return res;
+#endif
+}
+
+bool Motorola_EZX::setDisplayStatus( bool on )
+{
+ bool res = false;
+ int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
+ if ( fd )
+ {
+ char buf[10];
+ buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
+ buf[1] = '\0';
+ res = ( ::write( fd, &buf[0], 2 ) == 0 );
+ ::close( fd );
+ }
+ return res;
+}
+
+void Motorola_EZX::systemMessage( const QCString &msg, const QByteArray & )
+{
+ if ( msg == "deviceButtonMappingChanged()" ) {
+ reloadButtonMapping();
+ }
+}
+
+bool Motorola_EZX::suspend() {
+ if ( !isQWS( ) ) // only qwsserver is allowed to suspend
+ return false;
+
+ bool res = false;
+ QCopChannel::send( "QPE/System", "aboutToSuspend()" );
+
+ struct timeval tvs, tvn;
+ ::gettimeofday ( &tvs, 0 );
+
+ ::sync(); // flush fs caches
+ res = ( ::system ( "apm --suspend" ) == 0 );
+
+ QCopChannel::send( "QPE/System", "returnFromSuspend()" );
+
+ return res;
+}
diff --git a/libopie2/opiecore/device/odevice_motorola_ezx.h b/libopie2/opiecore/device/odevice_motorola_ezx.h
new file mode 100644
index 0000000..c0bd6c7
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_motorola_ezx.h
@@ -0,0 +1,102 @@
+/*
+                 This file is part of the Opie Project
+ =. (C) 2006 Michael 'Mickey' Lauer <mickey@Vanille.de>
+ .=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; version 2 of the License.
+     ._= =}       :
+    .%`+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 ODEVICE_MOTOROLA_EZX
+#define ODEVICE_MOTOROLA_EZX
+
+#include "odevice_abstractmobiledevice.h"
+
+/* QT */
+#include <qfile.h>
+#include <qwindowsystem_qws.h>
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
+// Audio
+// LED
+// Power Management
+#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
+#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
+#define APM_EVT_POWER_BUTTON (1 << 0)
+
+// Vesa Standard
+#define FB_BLANK_UNBLANK 0
+#define FB_BLANK_POWERDOWN 4
+
+namespace Opie {
+namespace Core {
+namespace Internal {
+
+class Motorola_EZX : public OAbstractMobileDevice
+{
+ Q_OBJECT
+
+ protected:
+ virtual void init(const QString&);
+ virtual void initButtons();
+ //void initHingeSensor();
+
+ protected slots:
+ //void hingeSensorTriggered();
+ void systemMessage( const QCString &msg, const QByteArray & );
+
+ public:
+ virtual bool setDisplayBrightness( int b );
+ virtual bool setDisplayStatus( bool on );
+ virtual int displayBrightnessResolution() const;
+
+ virtual void playAlarmSound();
+
+ virtual QValueList <OLed> ledList() const;
+ virtual QValueList <OLedState> ledStateList ( OLed led ) const;
+ virtual OLedState ledState( OLed led ) const;
+ virtual bool setLedState( OLed led, OLedState st );
+
+ virtual bool suspend();
+
+ protected:
+ QString m_backlightdev;
+ OLedState m_leds[1];
+ QFile m_hinge;
+};
+
+struct ezx_button {
+ Qt::Key code;
+ char *utext;
+ char *pix;
+ char *fpressedservice;
+ char *fpressedaction;
+ char *fheldservice;
+ char *fheldaction;
+};
+}
+}
+}
+#endif