summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp50
-rw-r--r--libopie2/opiecore/device/odevice.h43
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp43
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp43
4 files changed, 94 insertions, 85 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 72b9ac7..7d67efe 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,72 +1,72 @@
1/* 1/*
2                 This file is part of the Opie Project 2 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6 .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13    .%`+i>       _;_. 13 .%`+i> _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++=   -.     .`     .: details. 20++= -. .` .: details.
21 :     =  ...= . :.=- 21: = ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
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#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
49/* STD */ 49/* STD */
50#include <fcntl.h> 50#include <fcntl.h>
51#include <math.h> 51#include <math.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <signal.h> 53#include <signal.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 58#include <linux/soundcard.h>
59#endif 59#endif
60 60
61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
62 62
63using namespace Opie; 63using namespace Opie;
64 64
65ODevice *ODevice::inst() 65ODevice *ODevice::inst()
66{ 66{
67 static ODevice *dev = 0; 67 static ODevice *dev = 0;
68 68
69 // rewrite this to only use /proc/cpuinfo or so 69 // rewrite this to only use /proc/cpuinfo or so
70 70
71 if ( !dev ) 71 if ( !dev )
72 { 72 {
@@ -141,97 +141,98 @@ void ODevice::initButtons()
141 141
142 qDebug ( "init Buttons" ); 142 qDebug ( "init Buttons" );
143 d->m_buttons = new QValueList <ODeviceButton>; 143 d->m_buttons = new QValueList <ODeviceButton>;
144 144
145 reloadButtonMapping(); 145 reloadButtonMapping();
146 146
147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
148 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 148 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
149} 149}
150 150
151ODevice::~ODevice() 151ODevice::~ODevice()
152{ 152{
153// we leak m_devicebuttons and m_cpu_frequency 153// we leak m_devicebuttons and m_cpu_frequency
154// but it's a singleton and it is not so importantant 154// but it's a singleton and it is not so importantant
155// -zecke 155// -zecke
156 delete d; 156 delete d;
157} 157}
158 158
159bool ODevice::setSoftSuspend ( bool /*soft*/ ) 159bool ODevice::setSoftSuspend ( bool /*soft*/ )
160{ 160{
161 return false; 161 return false;
162} 162}
163 163
164//#include <linux/apm_bios.h> 164//#include <linux/apm_bios.h>
165 165
166#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 166#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
167 167
168/** 168/**
169* This method will try to suspend the device 169* This method will try to suspend the device
170* It only works if the user is the QWS Server and the apm application 170* It only works if the user is the QWS Server and the apm application
171* is installed. 171* is installed.
172* It tries to suspend and then waits some time cause some distributions 172* It tries to suspend and then waits some time cause some distributions
173* do have asynchronus apm implementations. 173* do have asynchronus apm implementations.
174* This method will either fail and return false or it'll suspend the 174* This method will either fail and return false or it'll suspend the
175* device and return once the device got woken up 175* device and return once the device got woken up
176* 176*
177* @return if the device got suspended 177* @return if the device got suspended
178*/ 178*/
179bool ODevice::suspend() 179bool ODevice::suspend()
180{ 180{
181 qDebug("ODevice::suspend"); 181 qDebug("ODevice::suspend");
182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
183 return false; 183 return false;
184 184
185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
186 return false; 186 return false;
187 187
188 bool res = false; 188 bool res = false;
189 189 ODevice::sendSuspendmsg();
190
190 struct timeval tvs, tvn; 191 struct timeval tvs, tvn;
191 ::gettimeofday ( &tvs, 0 ); 192 ::gettimeofday ( &tvs, 0 );
192 193
193 ::sync(); // flush fs caches 194 ::sync(); // flush fs caches
194 res = ( ::system ( "apm --suspend" ) == 0 ); 195 res = ( ::system ( "apm --suspend" ) == 0 );
195 196
196 // This is needed because the iPAQ apm implementation is asynchronous and we 197 // This is needed because the iPAQ apm implementation is asynchronous and we
197 // can not be sure when exactly the device is really suspended 198 // can not be sure when exactly the device is really suspended
198 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 199 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
199 200
200 if ( res ) { 201 if ( res ) {
201 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
202 ::usleep ( 200 * 1000 ); 203 ::usleep ( 200 * 1000 );
203 ::gettimeofday ( &tvn, 0 ); 204 ::gettimeofday ( &tvn, 0 );
204 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
205 } 206 }
206 207
207 return res; 208 return res;
208} 209}
209 210
210//#include <linux/fb.h> better not rely on kernel headers in userspace ... 211//#include <linux/fb.h> better not rely on kernel headers in userspace ...
211 212
212#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
213 214
214/* VESA Blanking Levels */ 215/* VESA Blanking Levels */
215#define VESA_NO_BLANKING 0 216#define VESA_NO_BLANKING 0
216#define VESA_VSYNC_SUSPEND 1 217#define VESA_VSYNC_SUSPEND 1
217#define VESA_HSYNC_SUSPEND 2 218#define VESA_HSYNC_SUSPEND 2
218#define VESA_POWERDOWN 3 219#define VESA_POWERDOWN 3
219 220
220/** 221/**
221* This sets the display on or off 222* This sets the display on or off
222*/ 223*/
223bool ODevice::setDisplayStatus ( bool on ) 224bool ODevice::setDisplayStatus ( bool on )
224{ 225{
225 qDebug("ODevice::setDisplayStatus(%d)", on); 226 qDebug("ODevice::setDisplayStatus(%d)", on);
226 227
227 if ( d->m_model == Model_Unknown ) 228 if ( d->m_model == Model_Unknown )
228 return false; 229 return false;
229 230
230 bool res = false; 231 bool res = false;
231 int fd; 232 int fd;
232 233
233 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
234 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
235 ::close ( fd ); 236 ::close ( fd );
236 } 237 }
237 return res; 238 return res;
@@ -575,48 +576,53 @@ void ODevice::reloadButtonMapping()
575} 576}
576 577
577void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 578void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
578{ 579{
579 initButtons(); 580 initButtons();
580 581
581 QString mb_chan; 582 QString mb_chan;
582 583
583 if ( button >= (int) d->m_buttons->count()) 584 if ( button >= (int) d->m_buttons->count())
584 return; 585 return;
585 586
586 ODeviceButton &b = ( *d->m_buttons ) [button]; 587 ODeviceButton &b = ( *d->m_buttons ) [button];
587 b. setPressedAction ( action ); 588 b. setPressedAction ( action );
588 589
589 mb_chan=b. pressedAction(). channel(); 590 mb_chan=b. pressedAction(). channel();
590 591
591 Config buttonFile ( "ButtonSettings" ); 592 Config buttonFile ( "ButtonSettings" );
592 buttonFile. setGroup ( "Button" + QString::number ( button )); 593 buttonFile. setGroup ( "Button" + QString::number ( button ));
593 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 594 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
594 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 595 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
595 596
596 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 597 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
597 598
598 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 599 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
599} 600}
600 601
601void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 602void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
602{ 603{
603 initButtons(); 604 initButtons();
604 605
605 if ( button >= (int) d->m_buttons->count()) 606 if ( button >= (int) d->m_buttons->count())
606 return; 607 return;
607 608
608 ODeviceButton &b = ( *d->m_buttons ) [button]; 609 ODeviceButton &b = ( *d->m_buttons ) [button];
609 b. setHeldAction ( action ); 610 b. setHeldAction ( action );
610 611
611 Config buttonFile ( "ButtonSettings" ); 612 Config buttonFile ( "ButtonSettings" );
612 buttonFile. setGroup ( "Button" + QString::number ( button )); 613 buttonFile. setGroup ( "Button" + QString::number ( button ));
613 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
614 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
615 616
616 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
617 618
618 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
619} 620}
620void ODevice::virtual_hook(int, void* ){ 621void ODevice::virtual_hook(int, void* ){
621 622
622} 623}
624
625void ODevice::sendSuspendmsg()
626{
627 QCopEnvelope ( "QPE/System", "aboutSuspend()" );
628}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 791ccb3..bccb449 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,72 +1,72 @@
1/* 1/*
2                 This file is part of the Opie Project 2 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6 .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13    .%`+i>       _;_. 13 .%`+i> _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++=   -.     .`     .: details. 20++= -. .` .: details.
21 :     =  ...= . :.=- 21: = ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
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_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qstrlist.h> 41#include <qstrlist.h>
42 42
43namespace Opie 43namespace Opie
44{ 44{
45 class ODeviceData; 45 class ODeviceData;
46/** 46/**
47 * The available devices 47 * The available devices
48 */ 48 */
49enum OModel { 49enum OModel {
50 Model_Unknown, // = 0 50 Model_Unknown, // = 0
51 51
52 Model_Series_Mask = 0xff000000, 52 Model_Series_Mask = 0xff000000,
53 53
54 Model_iPAQ = ( 1 << 24 ), 54 Model_iPAQ = ( 1 << 24 ),
55 55
56 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 56 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
57 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 57 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
58 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 58 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
59 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 59 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
60 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 60 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
61 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 61 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
62 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), 62 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ),
63 63
64 Model_Jornada = ( 6 << 24 ), 64 Model_Jornada = ( 6 << 24 ),
65 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 65 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
66 66
67 Model_Zaurus = ( 2 << 24 ), 67 Model_Zaurus = ( 2 << 24 ),
68 68
69 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 69 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
70 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 70 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
71 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 71 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
72 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 72 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
@@ -136,96 +136,97 @@ enum OHardKey {
136 HardKey_Datebook = Qt::Key_F9, 136 HardKey_Datebook = Qt::Key_F9,
137 HardKey_Contacts = Qt::Key_F10, 137 HardKey_Contacts = Qt::Key_F10,
138 HardKey_Menu = Qt::Key_F11, 138 HardKey_Menu = Qt::Key_F11,
139 HardKey_Home = Qt::Key_F12, 139 HardKey_Home = Qt::Key_F12,
140 HardKey_Mail = Qt::Key_F13, 140 HardKey_Mail = Qt::Key_F13,
141 HardKey_Record = Qt::Key_F24, 141 HardKey_Record = Qt::Key_F24,
142 HardKey_Suspend = Qt::Key_F34, 142 HardKey_Suspend = Qt::Key_F34,
143 HardKey_Backlight = Qt::Key_F35, 143 HardKey_Backlight = Qt::Key_F35,
144 HardKey_Action = Qt::Key_F10, 144 HardKey_Action = Qt::Key_F10,
145 HardKey_OK = Qt::Key_F11, 145 HardKey_OK = Qt::Key_F11,
146 HardKey_End = Qt::Key_F12, 146 HardKey_End = Qt::Key_F12,
147}; 147};
148 148
149enum ODirection { 149enum ODirection {
150 CW = 0, 150 CW = 0,
151 CCW = 1, 151 CCW = 1,
152 Flip = 2, 152 Flip = 2,
153}; 153};
154 154
155enum OHingeStatus { 155enum OHingeStatus {
156 CASE_CLOSED = 3, 156 CASE_CLOSED = 3,
157 CASE_PORTRAIT = 2, 157 CASE_PORTRAIT = 2,
158 CASE_LANDSCAPE = 0, 158 CASE_LANDSCAPE = 0,
159 CASE_UNKNOWN = 1, 159 CASE_UNKNOWN = 1,
160}; 160};
161 161
162/** 162/**
163 * A singleton which gives informations about device specefic option 163 * A singleton which gives informations about device specefic option
164 * like the Hardware used, LEDs, the Base Distribution and 164 * like the Hardware used, LEDs, the Base Distribution and
165 * hardware key mappings. 165 * hardware key mappings.
166 * 166 *
167 * @short A small class for device specefic options 167 * @short A small class for device specefic options
168 * @see QObject 168 * @see QObject
169 * @author Robert Griebl 169 * @author Robert Griebl
170 * @version 1.0 170 * @version 1.0
171 */ 171 */
172class ODevice : public QObject 172class ODevice : public QObject
173{ 173{
174 Q_OBJECT 174 Q_OBJECT
175 175
176private: 176private:
177 /* disable copy */ 177 /* disable copy */
178 ODevice ( const ODevice & ); 178 ODevice ( const ODevice & );
179 179
180protected: 180protected:
181 ODevice(); 181 ODevice();
182 virtual void init(); 182 virtual void init();
183 virtual void initButtons(); 183 virtual void initButtons();
184 static void sendSuspendmsg();
184 185
185 ODeviceData *d; 186 ODeviceData *d;
186 187
187public: 188public:
188 // sandman do we want to allow destructions? -zecke? 189 // sandman do we want to allow destructions? -zecke?
189 virtual ~ODevice(); 190 virtual ~ODevice();
190 191
191 static ODevice *inst(); 192 static ODevice *inst();
192 193
193 // information 194 // information
194 195
195 QString modelString() const; 196 QString modelString() const;
196 OModel model() const; 197 OModel model() const;
197 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } 198 inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
198 199
199 QString vendorString() const; 200 QString vendorString() const;
200 OVendor vendor() const; 201 OVendor vendor() const;
201 202
202 QString systemString() const; 203 QString systemString() const;
203 OSystem system() const; 204 OSystem system() const;
204 205
205 QString systemVersionString() const; 206 QString systemVersionString() const;
206 207
207 virtual Transformation rotation() const; 208 virtual Transformation rotation() const;
208 virtual ODirection direction() const; 209 virtual ODirection direction() const;
209 210
210 // system 211 // system
211 212
212 virtual bool setSoftSuspend ( bool on ); 213 virtual bool setSoftSuspend ( bool on );
213 virtual bool suspend(); 214 virtual bool suspend();
214 215
215 virtual bool setDisplayStatus ( bool on ); 216 virtual bool setDisplayStatus ( bool on );
216 virtual bool setDisplayBrightness ( int brightness ); 217 virtual bool setDisplayBrightness ( int brightness );
217 virtual int displayBrightnessResolution() const; 218 virtual int displayBrightnessResolution() const;
218 virtual bool setDisplayContrast ( int contrast ); 219 virtual bool setDisplayContrast ( int contrast );
219 virtual int displayContrastResolution() const; 220 virtual int displayContrastResolution() const;
220 221
221 // don't add new virtual methods, use this: 222 // don't add new virtual methods, use this:
222 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 223 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
223 // and in your subclass do do overwrite 224 // and in your subclass do do overwrite
224 //protected virtual int virtual_hook(int, void *) 225 //protected virtual int virtual_hook(int, void *)
225 // which is defined below 226 // which is defined below
226 227
227 // input / output 228 // input / output
228 virtual void playAlarmSound(); 229 virtual void playAlarmSound();
229 virtual void playKeySound(); 230 virtual void playKeySound();
230 virtual void playTouchSound(); 231 virtual void playTouchSound();
231 232
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 4397b78..31b9297 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,72 +1,72 @@
1/* 1/*
2                 This file is part of the Opie Project 2 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6 .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13    .%`+i>       _;_. 13 .%`+i> _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++=   -.     .`     .: details. 20++= -. .` .: details.
21 :     =  ...= . :.=- 21: = ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
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#include "odevice_simpad.h" 30#include "odevice_simpad.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie; 56using namespace Opie;
57 57
58struct s_button simpad_buttons [] = { 58struct s_button simpad_buttons [] = {
59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
61 "devicebuttons/simpad_lower_up", 61 "devicebuttons/simpad_lower_up",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
66 "devicebuttons/simpad_lower_down", 66 "devicebuttons/simpad_lower_down",
67 "addressbook", "raise()", 67 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 68 "addressbook", "beamBusinessCard()" },
69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
71 "devicebuttons/simpad_lower_right", 71 "devicebuttons/simpad_lower_right",
72 "QPE/TaskBar", "toggleMenu()", 72 "QPE/TaskBar", "toggleMenu()",
@@ -281,96 +281,97 @@ void SIMpad::timerEvent ( QTimerEvent * )
281} 281}
282 282
283 283
284void SIMpad::playAlarmSound() 284void SIMpad::playAlarmSound()
285{ 285{
286#ifndef QT_NO_SOUND 286#ifndef QT_NO_SOUND
287 static Sound snd ( "alarm" ); 287 static Sound snd ( "alarm" );
288 int fd; 288 int fd;
289 int vol; 289 int vol;
290 bool vol_reset = false; 290 bool vol_reset = false;
291 291
292 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 292 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
293 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 293 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
294 Config cfg ( "qpe" ); 294 Config cfg ( "qpe" );
295 cfg. setGroup ( "Volume" ); 295 cfg. setGroup ( "Volume" );
296 296
297 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 297 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
298 if ( volalarm < 0 ) 298 if ( volalarm < 0 )
299 volalarm = 0; 299 volalarm = 0;
300 else if ( volalarm > 100 ) 300 else if ( volalarm > 100 )
301 volalarm = 100; 301 volalarm = 100;
302 volalarm |= ( volalarm << 8 ); 302 volalarm |= ( volalarm << 8 );
303 303
304 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 304 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
305 vol_reset = true; 305 vol_reset = true;
306 } 306 }
307 } 307 }
308 308
309 snd. play(); 309 snd. play();
310 while ( !snd. isFinished()) 310 while ( !snd. isFinished())
311 qApp->processEvents(); 311 qApp->processEvents();
312 312
313 if ( fd >= 0 ) { 313 if ( fd >= 0 ) {
314 if ( vol_reset ) 314 if ( vol_reset )
315 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 315 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
316 ::close ( fd ); 316 ::close ( fd );
317 } 317 }
318#endif 318#endif
319} 319}
320 320
321 321
322bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 322bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
323{ 323{
324 qDebug( "ODevice for SIMpad: suspend()" ); 324 qDebug( "ODevice for SIMpad: suspend()" );
325 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 325 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
326 return false; 326 return false;
327 327
328 bool res = false; 328 bool res = false;
329 ODevice::sendSuspendmsg();
329 330
330 struct timeval tvs, tvn; 331 struct timeval tvs, tvn;
331 ::gettimeofday ( &tvs, 0 ); 332 ::gettimeofday ( &tvs, 0 );
332 333
333 ::sync(); // flush fs caches 334 ::sync(); // flush fs caches
334 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 335 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
335 336
336 return res; 337 return res;
337} 338}
338 339
339 340
340bool SIMpad::setSoftSuspend ( bool soft ) 341bool SIMpad::setSoftSuspend ( bool soft )
341{ 342{
342 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 343 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
343 return false; 344 return false;
344} 345}
345 346
346 347
347bool SIMpad::setDisplayStatus ( bool on ) 348bool SIMpad::setDisplayStatus ( bool on )
348{ 349{
349 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 350 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
350 351
351 bool res = false; 352 bool res = false;
352 int fd; 353 int fd;
353 354
354 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 355 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
355 356
356 res = ( ::system( (const char*) cmdline ) == 0 ); 357 res = ( ::system( (const char*) cmdline ) == 0 );
357 358
358 return res; 359 return res;
359} 360}
360 361
361 362
362bool SIMpad::setDisplayBrightness ( int bright ) 363bool SIMpad::setDisplayBrightness ( int bright )
363{ 364{
364 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 365 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
365 bool res = false; 366 bool res = false;
366 int fd; 367 int fd;
367 368
368 if ( bright > 255 ) 369 if ( bright > 255 )
369 bright = 255; 370 bright = 255;
370 if ( bright < 1 ) 371 if ( bright < 1 )
371 bright = 0; 372 bright = 0;
372 373
373 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 374 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
374 int value = 255 - bright; 375 int value = 255 - bright;
375 const int mask = SIMPAD_BACKLIGHT_MASK; 376 const int mask = SIMPAD_BACKLIGHT_MASK;
376 value = value << 8; 377 value = value << 8;
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 8bff770..9d23a12 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,72 +1,72 @@
1/* 1/*
2                 This file is part of the Opie Project 2 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6 .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13    .%`+i>       _;_. 13 .%`+i> _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++=   -.     .`     .: details. 20++= -. .` .: details.
21 :     =  ...= . :.=- 21: = ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
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#include "odevice_zaurus.h" 30#include "odevice_zaurus.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie; 56using namespace Opie;
57 57
58struct z_button z_buttons [] = { 58struct z_button z_buttons [] = {
59 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 59 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
60 "devicebuttons/z_calendar", 60 "devicebuttons/z_calendar",
61 "datebook", "nextView()", 61 "datebook", "nextView()",
62 "today", "raise()" }, 62 "today", "raise()" },
63 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 63 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
64 "devicebuttons/z_contact", 64 "devicebuttons/z_contact",
65 "addressbook", "raise()", 65 "addressbook", "raise()",
66 "addressbook", "beamBusinessCard()" }, 66 "addressbook", "beamBusinessCard()" },
67 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 67 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
68 "devicebuttons/z_home", 68 "devicebuttons/z_home",
69 "QPE/Launcher", "home()", 69 "QPE/Launcher", "home()",
70 "buttonsettings", "raise()" }, 70 "buttonsettings", "raise()" },
71 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 71 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
72 "devicebuttons/z_menu", 72 "devicebuttons/z_menu",
@@ -521,96 +521,97 @@ bool Zaurus::setDisplayBrightness ( int bright )
521 if ( d->m_model == Model_Zaurus_SLC7x0 ) 521 if ( d->m_model == Model_Zaurus_SLC7x0 )
522 { 522 {
523 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 523 //qDebug( "using special treatment for devices with the corgi backlight interface" );
524 // special treatment for devices with the corgi backlight interface 524 // special treatment for devices with the corgi backlight interface
525 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 525 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
526 { 526 {
527 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); 527 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 );
528 char writeCommand[100]; 528 char writeCommand[100];
529 const int count = sprintf( writeCommand, "0x%x\n", value ); 529 const int count = sprintf( writeCommand, "0x%x\n", value );
530 res = ( ::write ( fd, writeCommand, count ) != -1 ); 530 res = ( ::write ( fd, writeCommand, count ) != -1 );
531 ::close ( fd ); 531 ::close ( fd );
532 } 532 }
533 return res; 533 return res;
534 } 534 }
535 else 535 else
536 { 536 {
537 // standard treatment for devices with the dumb embedix frontlight interface 537 // standard treatment for devices with the dumb embedix frontlight interface
538 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 538 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
539 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 539 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
540 if ( bright && !bl ) 540 if ( bright && !bl )
541 bl = 1; 541 bl = 1;
542 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 542 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
543 ::close ( fd ); 543 ::close ( fd );
544 } 544 }
545 } 545 }
546 } 546 }
547 else 547 else
548 { 548 {
549 // special treatment for the OpenZaurus unified interface 549 // special treatment for the OpenZaurus unified interface
550 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 550 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
551 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 551 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
552 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 552 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
553 ::close ( fd ); 553 ::close ( fd );
554 } 554 }
555 } 555 }
556 return res; 556 return res;
557} 557}
558 558
559bool Zaurus::suspend() 559bool Zaurus::suspend()
560{ 560{
561 qDebug("ODevice::suspend"); 561 qDebug("ODevice::suspend");
562 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 562 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
563 return false; 563 return false;
564 564
565 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 565 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
566 return false; 566 return false;
567 567
568 bool res = false; 568 bool res = false;
569 ODevice::sendSuspendmsg();
569 570
570 struct timeval tvs, tvn; 571 struct timeval tvs, tvn;
571 ::gettimeofday ( &tvs, 0 ); 572 ::gettimeofday ( &tvs, 0 );
572 573
573 ::sync(); // flush fs caches 574 ::sync(); // flush fs caches
574 res = ( ::system ( "apm --suspend" ) == 0 ); 575 res = ( ::system ( "apm --suspend" ) == 0 );
575 576
576 // This is needed because the iPAQ apm implementation is asynchronous and we 577 // This is needed because the iPAQ apm implementation is asynchronous and we
577 // can not be sure when exactly the device is really suspended 578 // can not be sure when exactly the device is really suspended
578 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 579 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
579 580
580 if ( res ) { 581 if ( res ) {
581 do { // Yes, wait 15 seconds. This APM bug sucks big time. 582 do { // Yes, wait 15 seconds. This APM bug sucks big time.
582 ::usleep ( 200 * 1000 ); 583 ::usleep ( 200 * 1000 );
583 ::gettimeofday ( &tvn, 0 ); 584 ::gettimeofday ( &tvn, 0 );
584 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 585 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
585 } 586 }
586 587
587 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 588 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
588 return res; 589 return res;
589} 590}
590 591
591 592
592Transformation Zaurus::rotation() const 593Transformation Zaurus::rotation() const
593{ 594{
594 Transformation rot; 595 Transformation rot;
595 int handle = 0; 596 int handle = 0;
596 int retval = 0; 597 int retval = 0;
597 598
598 switch ( d->m_model ) { 599 switch ( d->m_model ) {
599 case Model_Zaurus_SLC7x0: 600 case Model_Zaurus_SLC7x0:
600 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 601 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
601 if (handle == -1) { 602 if (handle == -1) {
602 return Rot270; 603 return Rot270;
603 } else { 604 } else {
604 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 605 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
605 ::close (handle); 606 ::close (handle);
606 607
607 if (retval == 2 ) 608 if (retval == 2 )
608 rot = Rot0; 609 rot = Rot0;
609 else 610 else
610 rot = Rot270; 611 rot = Rot270;
611 } 612 }
612 break; 613 break;
613 case Model_Zaurus_SLA300: 614 case Model_Zaurus_SLA300:
614 case Model_Zaurus_SLB600: 615 case Model_Zaurus_SLB600:
615 case Model_Zaurus_SL5500: 616 case Model_Zaurus_SL5500:
616 case Model_Zaurus_SL5000: 617 case Model_Zaurus_SL5000: