summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-06-09 09:14:22 (UTC)
committer mickeyl <mickeyl>2005-06-09 09:14:22 (UTC)
commit9a4b3a90fdd4ac0288034657d4818e3d10ed0193 (patch) (unidiff)
treeb65dc74dce17f4f709242753152b53767bb1a4fc
parent15978c2609cc29d2eb2b21922dd52627015889c1 (diff)
downloadopie-9a4b3a90fdd4ac0288034657d4818e3d10ed0193.zip
opie-9a4b3a90fdd4ac0288034657d4818e3d10ed0193.tar.gz
opie-9a4b3a90fdd4ac0288034657d4818e3d10ed0193.tar.bz2
add support for the linux 2.6 backlight interface on tosa, poodle, and collie
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp65
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h5
2 files changed, 42 insertions, 28 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 1742100..21d2342 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,656 +1,669 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; version 2 of the License.
13     ._= =}       : or (at your option) any later version. 12     ._= =}       :
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22:     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29*/ 28*/
30 29
31#include "odevice_zaurus.h" 30#include "odevice_zaurus.h"
32 31
33/* QT */ 32/* QT */
34#include <qapplication.h> 33#include <qapplication.h>
35#include <qfile.h> 34#include <qfile.h>
36#include <qtextstream.h> 35#include <qtextstream.h>
37#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
38 37
39/* OPIE */ 38/* OPIE */
40#include <opie2/oinputsystem.h> 39#include <opie2/oinputsystem.h>
41#include <opie2/oresource.h> 40#include <opie2/oresource.h>
42 41
43#include <qpe/config.h> 42#include <qpe/config.h>
44#include <qpe/sound.h> 43#include <qpe/sound.h>
45#include <qpe/qcopenvelope_qws.h> 44#include <qpe/qcopenvelope_qws.h>
46 45
47/* STD */ 46/* STD */
48#include <fcntl.h> 47#include <fcntl.h>
49#include <math.h> 48#include <math.h>
50#include <stdlib.h> 49#include <stdlib.h>
51#include <signal.h> 50#include <signal.h>
52#include <sys/ioctl.h> 51#include <sys/ioctl.h>
53#include <sys/time.h> 52#include <sys/time.h>
54#include <unistd.h> 53#include <unistd.h>
55#ifndef QT_NO_SOUND 54#ifndef QT_NO_SOUND
56#include <linux/soundcard.h> 55#include <linux/soundcard.h>
57#endif 56#endif
58 57
59using namespace Opie::Core; 58using namespace Opie::Core;
60using namespace Opie::Core::Internal; 59using namespace Opie::Core::Internal;
61 60
62struct z_button z_buttons [] = { 61struct z_button z_buttons [] = {
63 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 62 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
64 "devicebuttons/z_calendar", 63 "devicebuttons/z_calendar",
65 "datebook", "nextView()", 64 "datebook", "nextView()",
66 "today", "raise()" }, 65 "today", "raise()" },
67 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 66 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
68 "devicebuttons/z_contact", 67 "devicebuttons/z_contact",
69 "addressbook", "raise()", 68 "addressbook", "raise()",
70 "addressbook", "beamBusinessCard()" }, 69 "addressbook", "beamBusinessCard()" },
71 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 70 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
72 "devicebuttons/z_home", 71 "devicebuttons/z_home",
73 "QPE/Launcher", "home()", 72 "QPE/Launcher", "home()",
74 "buttonsettings", "raise()" }, 73 "buttonsettings", "raise()" },
75 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 74 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
76 "devicebuttons/z_menu", 75 "devicebuttons/z_menu",
77 "QPE/TaskBar", "toggleMenu()", 76 "QPE/TaskBar", "toggleMenu()",
78 "QPE/TaskBar", "toggleStartMenu()" }, 77 "QPE/TaskBar", "toggleStartMenu()" },
79 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 78 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
80 "devicebuttons/z_mail", 79 "devicebuttons/z_mail",
81 "opiemail", "raise()", 80 "opiemail", "raise()",
82 "opiemail", "newMail()" }, 81 "opiemail", "newMail()" },
83}; 82};
84 83
85struct z_button z_buttons_c700 [] = { 84struct z_button z_buttons_c700 [] = {
86 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 85 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
87 "devicebuttons/z_calendar", 86 "devicebuttons/z_calendar",
88 "datebook", "nextView()", 87 "datebook", "nextView()",
89 "today", "raise()" }, 88 "today", "raise()" },
90 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 89 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
91 "devicebuttons/z_contact", 90 "devicebuttons/z_contact",
92 "addressbook", "raise()", 91 "addressbook", "raise()",
93 "addressbook", "beamBusinessCard()" }, 92 "addressbook", "beamBusinessCard()" },
94 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 93 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
95 "devicebuttons/z_home", 94 "devicebuttons/z_home",
96 "QPE/Launcher", "home()", 95 "QPE/Launcher", "home()",
97 "buttonsettings", "raise()" }, 96 "buttonsettings", "raise()" },
98 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 97 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
99 "devicebuttons/z_menu", 98 "devicebuttons/z_menu",
100 "QPE/TaskBar", "toggleMenu()", 99 "QPE/TaskBar", "toggleMenu()",
101 "QPE/TaskBar", "toggleStartMenu()" }, 100 "QPE/TaskBar", "toggleStartMenu()" },
102 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 101 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
103 "devicebuttons/z_mail", 102 "devicebuttons/z_mail",
104 "opiemail", "raise()", 103 "opiemail", "raise()",
105 "opiemail", "newMail()" }, 104 "opiemail", "newMail()" },
106 105
107 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), 106 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"),
108 "devicebuttons/z_hinge1", 107 "devicebuttons/z_hinge1",
109 "QPE/Rotation", "rotateDefault()",0}, 108 "QPE/Rotation", "rotateDefault()",0},
110 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), 109 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"),
111 "devicebuttons/z_hinge2", 110 "devicebuttons/z_hinge2",
112 "QPE/Rotation", "rotateDefault()",0}, 111 "QPE/Rotation", "rotateDefault()",0},
113 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), 112 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
114 "devicebuttons/z_hinge3", 113 "devicebuttons/z_hinge3",
115 "QPE/Rotation", "rotateDefault()",0}, 114 "QPE/Rotation", "rotateDefault()",0},
116}; 115};
117 116
118// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 117// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
119// class up into individual classes. We would need three classes 118// class up into individual classes. We would need three classes
120// 119//
121// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 120// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
122// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 121// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
123// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000) 122// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100)
124// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) 123// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
125 124
126void Zaurus::init(const QString& cpu_info) 125void Zaurus::init(const QString& cpu_info)
127{ 126{
128 // Set the time to wait until the system is really suspended 127 // Set the time to wait until the system is really suspended
129 // the delta between apm --suspend and sleeping 128 // the delta between apm --suspend and sleeping
130 setAPMTimeOut( 15000 ); 129 setAPMTimeOut( 15000 );
131 130
132 // generic distribution code already scanned /etc/issue at that point - 131 // generic distribution code already scanned /etc/issue at that point -
133 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 132 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
134 if ( d->m_sysverstr.contains( "embedix", false ) ) 133 if ( d->m_sysverstr.contains( "embedix", false ) )
135 { 134 {
136 d->m_vendorstr = "Sharp"; 135 d->m_vendorstr = "Sharp";
137 d->m_vendor = Vendor_Sharp; 136 d->m_vendor = Vendor_Sharp;
138 d->m_systemstr = "Zaurus"; 137 d->m_systemstr = "Zaurus";
139 d->m_system = System_Zaurus; 138 d->m_system = System_Zaurus;
140 m_embedix = true; 139 m_embedix = true;
141 } 140 }
142 else 141 else
143 { 142 {
144 d->m_vendorstr = "OpenZaurus Team"; 143 d->m_vendorstr = "OpenZaurus Team";
145 d->m_systemstr = "OpenZaurus"; 144 d->m_systemstr = "OpenZaurus";
146 d->m_system = System_OpenZaurus; 145 d->m_system = System_OpenZaurus;
147 // sysver already gathered 146 // sysver already gathered
148 147
149 // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one 148 // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one
150 FILE *uname = popen("uname -r", "r"); 149 FILE *uname = popen("uname -r", "r");
151 QFile f; 150 QFile f;
152 QString line; 151 QString line;
153 if ( f.open(IO_ReadOnly, uname) ) { 152 if ( f.open(IO_ReadOnly, uname) ) {
154 QTextStream ts ( &f ); 153 QTextStream ts ( &f );
155 line = ts.readLine(); 154 line = ts.readLine();
156 m_embedix = line.startsWith( "2.4." ); 155 m_embedix = line.startsWith( "2.4." );
157 f.close(); 156 f.close();
158 } 157 }
159 pclose(uname); 158 pclose(uname);
160 } 159 }
161 160
162 // check the Zaurus model 161 // check the Zaurus model
163 QString model; 162 QString model;
164 int loc = cpu_info.find( ":" ); 163 int loc = cpu_info.find( ":" );
165 if ( loc != -1 ) 164 if ( loc != -1 )
166 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 165 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
167 else 166 else
168 model = cpu_info; 167 model = cpu_info;
169 168
170 if ( model == "SHARP Corgi" ) { 169 if ( model == "SHARP Corgi" ) {
171 d->m_model = Model_Zaurus_SLC7x0; 170 d->m_model = Model_Zaurus_SLC7x0;
172 d->m_modelstr = "Zaurus SL-C700"; 171 d->m_modelstr = "Zaurus SL-C700";
173 } else if ( model == "SHARP Shepherd" ) { 172 } else if ( model == "SHARP Shepherd" ) {
174 d->m_model = Model_Zaurus_SLC7x0; 173 d->m_model = Model_Zaurus_SLC7x0;
175 d->m_modelstr = "Zaurus SL-C750"; 174 d->m_modelstr = "Zaurus SL-C750";
176 } else if ( model == "SHARP Husky" ) { 175 } else if ( model == "SHARP Husky" ) {
177 d->m_model = Model_Zaurus_SLC7x0; 176 d->m_model = Model_Zaurus_SLC7x0;
178 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 177 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
179 } else if ( model == "SHARP Boxer" ) { 178 } else if ( model == "SHARP Boxer" ) {
180 d->m_model = Model_Zaurus_SLC7x0; 179 d->m_model = Model_Zaurus_SLC7x0;
181 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 180 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
182 } else if ( model == "SHARP Poodle" ) { 181 } else if ( model == "SHARP Poodle" ) {
183 d->m_model = Model_Zaurus_SLB600; 182 d->m_model = Model_Zaurus_SLB600;
184 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 183 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
185 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 184 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
186 d->m_model = Model_Zaurus_SL5500; 185 d->m_model = Model_Zaurus_SL5500;
187 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 186 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
188 } else if ( model == "SHARP Tosa" ) { 187 } else if ( model == "SHARP Tosa" ) {
189 d->m_model = Model_Zaurus_SL6000; 188 d->m_model = Model_Zaurus_SL6000;
190 d->m_modelstr = "Zaurus SL-6000"; 189 d->m_modelstr = "Zaurus SL-6000";
191 } else if ( model == "SHARP Spitz" ) { 190 } else if ( model == "SHARP Spitz" ) {
192 d->m_model = Model_Zaurus_SLC3000; 191 d->m_model = Model_Zaurus_SLC3000;
193 d->m_modelstr = "Zaurus SL-C3000"; 192 d->m_modelstr = "Zaurus SL-C3000";
194 } else if ( model == "SHARP Akita" ) { 193 } else if ( model == "SHARP Akita" ) {
195 d->m_model = Model_Zaurus_SLC1000; 194 d->m_model = Model_Zaurus_SLC1000;
196 d->m_modelstr = "Zaurus SL-C1000"; 195 d->m_modelstr = "Zaurus SL-C1000";
197 } else { 196 } else {
198 d->m_model = Model_Zaurus_SL5500; 197 d->m_model = Model_Zaurus_SL5500;
199 d->m_modelstr = "Unknown Zaurus"; 198 d->m_modelstr = "Unknown Zaurus";
200 } 199 }
201 200
201 // set path to backlight device in kernel 2.6
202 switch ( d->m_model ) {
203 case Model_Zaurus_SLB600: // fallthrough
204 case Model_Zaurus_SL5500:
205 m_backlightdev = "/sys/class/backlight/locomo-backlight/";
206 break;
207 case Model_Zaurus_SL6000:
208 m_backlightdev = "/sys/class/backlight/tosa-bl/";
209 break;
210 default:
211 m_backlightdev = "/sys/class/backlight/corgi-bl/";
212 break;
213 }
214
202 // set initial rotation 215 // set initial rotation
203 switch( d->m_model ) { 216 switch( d->m_model ) {
204 case Model_Zaurus_SL6000: // fallthrough 217 case Model_Zaurus_SL6000: // fallthrough
205 case Model_Zaurus_SLA300: 218 case Model_Zaurus_SLA300:
206 d->m_rotation = Rot0; 219 d->m_rotation = Rot0;
207 break; 220 break;
208 case Model_Zaurus_SLC3000: // fallthrough 221 case Model_Zaurus_SLC3000: // fallthrough
209 case Model_Zaurus_SLC1000: // fallthrough 222 case Model_Zaurus_SLC1000: // fallthrough
210 case Model_Zaurus_SLC7x0: 223 case Model_Zaurus_SLC7x0:
211 d->m_rotation = rotation(); 224 d->m_rotation = rotation();
212 d->m_direction = direction(); 225 d->m_direction = direction();
213 break; 226 break;
214 case Model_Zaurus_SLB600: // fallthrough 227 case Model_Zaurus_SLB600: // fallthrough
215 case Model_Zaurus_SL5000: // fallthrough 228 case Model_Zaurus_SL5000: // fallthrough
216 case Model_Zaurus_SL5500: // fallthrough 229 case Model_Zaurus_SL5500: // fallthrough
217 default: 230 default:
218 d->m_rotation = Rot270; 231 d->m_rotation = Rot270;
219 break; 232 break;
220 } 233 }
221 m_leds[0] = Led_Off; 234 m_leds[0] = Led_Off;
222 235
223 if ( m_embedix ) 236 if ( m_embedix )
224 qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); 237 qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr );
225 else 238 else
226 qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 239 qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
227} 240}
228 241
229void Zaurus::initButtons() 242void Zaurus::initButtons()
230{ 243{
231 if ( d->m_buttons ) 244 if ( d->m_buttons )
232 return; 245 return;
233 246
234 247
235 d->m_buttons = new QValueList <ODeviceButton>; 248 d->m_buttons = new QValueList <ODeviceButton>;
236 249
237 struct z_button * pz_buttons; 250 struct z_button * pz_buttons;
238 int buttoncount; 251 int buttoncount;
239 switch ( d->m_model ) { 252 switch ( d->m_model ) {
240 case Model_Zaurus_SLC3000: // fallthrough 253 case Model_Zaurus_SLC3000: // fallthrough
241 case Model_Zaurus_SLC1000: // fallthrough 254 case Model_Zaurus_SLC1000: // fallthrough
242 case Model_Zaurus_SLC7x0: 255 case Model_Zaurus_SLC7x0:
243 if ( isQWS( ) ) { 256 if ( isQWS( ) ) {
244 addPreHandler(this); // hinge-sensor-handler 257 addPreHandler(this); // hinge-sensor-handler
245 } 258 }
246 pz_buttons = z_buttons_c700; 259 pz_buttons = z_buttons_c700;
247 buttoncount = ARRAY_SIZE(z_buttons_c700); 260 buttoncount = ARRAY_SIZE(z_buttons_c700);
248 break; 261 break;
249 default: 262 default:
250 pz_buttons = z_buttons; 263 pz_buttons = z_buttons;
251 buttoncount = ARRAY_SIZE(z_buttons); 264 buttoncount = ARRAY_SIZE(z_buttons);
252 break; 265 break;
253 } 266 }
254 267
255 for ( int i = 0; i < buttoncount; i++ ) { 268 for ( int i = 0; i < buttoncount; i++ ) {
256 struct z_button *zb = pz_buttons + i; 269 struct z_button *zb = pz_buttons + i;
257 ODeviceButton b; 270 ODeviceButton b;
258 271
259 b.setKeycode( zb->code ); 272 b.setKeycode( zb->code );
260 b.setUserText( QObject::tr( "Button", zb->utext )); 273 b.setUserText( QObject::tr( "Button", zb->utext ));
261 b.setPixmap( OResource::loadPixmap( zb->pix )); 274 b.setPixmap( OResource::loadPixmap( zb->pix ));
262 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 275 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
263 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 276 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
264 d->m_buttons->append( b ); 277 d->m_buttons->append( b );
265 } 278 }
266 279
267 reloadButtonMapping(); 280 reloadButtonMapping();
268} 281}
269 282
270 283
271 284
272typedef struct sharp_led_status { 285typedef struct sharp_led_status {
273 int which; /* select which LED status is wanted. */ 286 int which; /* select which LED status is wanted. */
274 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 287 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
275} sharp_led_status; 288} sharp_led_status;
276 289
277void Zaurus::buzzer( int sound ) 290void Zaurus::buzzer( int sound )
278{ 291{
279#ifndef QT_NO_SOUND 292#ifndef QT_NO_SOUND
280 Sound *snd = 0; 293 Sound *snd = 0;
281 294
282 // All devices except SL5500 have a DSP device 295 // All devices except SL5500 have a DSP device
283 if ( d->m_model != Model_Zaurus_SL5000 296 if ( d->m_model != Model_Zaurus_SL5000
284 && d->m_model != Model_Zaurus_SL5500 ) { 297 && d->m_model != Model_Zaurus_SL5500 ) {
285 298
286 switch ( sound ){ 299 switch ( sound ){
287 case SHARP_BUZ_TOUCHSOUND: { 300 case SHARP_BUZ_TOUCHSOUND: {
288 static Sound touch_sound("touchsound"); 301 static Sound touch_sound("touchsound");
289 snd = &touch_sound; 302 snd = &touch_sound;
290 } 303 }
291 break; 304 break;
292 case SHARP_BUZ_KEYSOUND: { 305 case SHARP_BUZ_KEYSOUND: {
293 static Sound key_sound( "keysound" ); 306 static Sound key_sound( "keysound" );
294 snd = &key_sound; 307 snd = &key_sound;
295 } 308 }
296 break; 309 break;
297 case SHARP_BUZ_SCHEDULE_ALARM: 310 case SHARP_BUZ_SCHEDULE_ALARM:
298 default: { 311 default: {
299 static Sound alarm_sound("alarm"); 312 static Sound alarm_sound("alarm");
300 snd = &alarm_sound; 313 snd = &alarm_sound;
301 } 314 }
302 break; 315 break;
303 } 316 }
304 } 317 }
305 318
306 // If a soundname is defined, we expect that this device has 319 // If a soundname is defined, we expect that this device has
307 // sound capabilities.. Otherwise we expect to have the buzzer 320 // sound capabilities.. Otherwise we expect to have the buzzer
308 // device.. 321 // device..
309 if ( snd && snd->isFinished() ){ 322 if ( snd && snd->isFinished() ){
310 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 323 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
311 snd->play(); 324 snd->play();
312 } else if( !snd ) { 325 } else if( !snd ) {
313 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 326 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
314 327
315 if ( fd >= 0 ) { 328 if ( fd >= 0 ) {
316 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 329 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
317 ::close ( fd ); 330 ::close ( fd );
318 } 331 }
319 332
320 } 333 }
321#endif 334#endif
322} 335}
323 336
324 337
325void Zaurus::playAlarmSound() 338void Zaurus::playAlarmSound()
326{ 339{
327 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 340 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
328} 341}
329 342
330void Zaurus::playTouchSound() 343void Zaurus::playTouchSound()
331{ 344{
332 buzzer( SHARP_BUZ_TOUCHSOUND ); 345 buzzer( SHARP_BUZ_TOUCHSOUND );
333} 346}
334 347
335void Zaurus::playKeySound() 348void Zaurus::playKeySound()
336{ 349{
337 buzzer( SHARP_BUZ_KEYSOUND ); 350 buzzer( SHARP_BUZ_KEYSOUND );
338} 351}
339 352
340 353
341QValueList <OLed> Zaurus::ledList() const 354QValueList <OLed> Zaurus::ledList() const
342{ 355{
343 QValueList <OLed> vl; 356 QValueList <OLed> vl;
344 vl << Led_Mail; 357 vl << Led_Mail;
345 return vl; 358 return vl;
346} 359}
347 360
348QValueList <OLedState> Zaurus::ledStateList( OLed l ) const 361QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
349{ 362{
350 QValueList <OLedState> vl; 363 QValueList <OLedState> vl;
351 364
352 if ( l == Led_Mail ) 365 if ( l == Led_Mail )
353 vl << Led_Off << Led_On << Led_BlinkSlow; 366 vl << Led_Off << Led_On << Led_BlinkSlow;
354 return vl; 367 return vl;
355} 368}
356 369
357OLedState Zaurus::ledState( OLed which ) const 370OLedState Zaurus::ledState( OLed which ) const
358{ 371{
359 if ( which == Led_Mail ) 372 if ( which == Led_Mail )
360 return m_leds [0]; 373 return m_leds [0];
361 else 374 else
362 return Led_Off; 375 return Led_Off;
363} 376}
364 377
365bool Zaurus::setLedState( OLed which, OLedState st ) 378bool Zaurus::setLedState( OLed which, OLedState st )
366{ 379{
367 // Currently not supported on non_embedix kernels 380 // Currently not supported on non_embedix kernels
368 if (!m_embedix) 381 if (!m_embedix)
369 { 382 {
370 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); 383 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
371 return false; 384 return false;
372 } 385 }
373 386
374 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 387 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
375 388
376 if ( which == Led_Mail ) { 389 if ( which == Led_Mail ) {
377 if ( fd >= 0 ) { 390 if ( fd >= 0 ) {
378 struct sharp_led_status leds; 391 struct sharp_led_status leds;
379 ::memset ( &leds, 0, sizeof( leds )); 392 ::memset ( &leds, 0, sizeof( leds ));
380 leds. which = SHARP_LED_MAIL_EXISTS; 393 leds. which = SHARP_LED_MAIL_EXISTS;
381 bool ok = true; 394 bool ok = true;
382 395
383 switch ( st ) { 396 switch ( st ) {
384 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 397 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
385 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 398 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
386 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 399 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
387 default : ok = false; 400 default : ok = false;
388 } 401 }
389 402
390 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 403 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
391 m_leds [0] = st; 404 m_leds [0] = st;
392 return true; 405 return true;
393 } 406 }
394 } 407 }
395 } 408 }
396 return false; 409 return false;
397} 410}
398 411
399int Zaurus::displayBrightnessResolution() const 412int Zaurus::displayBrightnessResolution() const
400{ 413{
401 int res = 1; 414 int res = 1;
402 if (m_embedix) 415 if (m_embedix)
403 { 416 {
404 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 417 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
405 if ( fd ) 418 if ( fd )
406 { 419 {
407 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); 420 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
408 ::close( fd ); 421 ::close( fd );
409 return value ? value : res; 422 return value ? value : res;
410 } 423 }
411 } 424 }
412 else 425 else
413 { 426 {
414 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); 427 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
415 if ( fd ) 428 if ( fd )
416 { 429 {
417 char buf[100]; 430 char buf[100];
418 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 431 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
419 ::close( fd ); 432 ::close( fd );
420 } 433 }
421 } 434 }
422 return res; 435 return res;
423} 436}
424 437
425bool Zaurus::setDisplayBrightness( int bright ) 438bool Zaurus::setDisplayBrightness( int bright )
426{ 439{
427 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 440 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
428 bool res = false; 441 bool res = false;
429 442
430 if ( bright > 255 ) bright = 255; 443 if ( bright > 255 ) bright = 255;
431 if ( bright < 0 ) bright = 0; 444 if ( bright < 0 ) bright = 0;
432 445
433 int numberOfSteps = displayBrightnessResolution(); 446 int numberOfSteps = displayBrightnessResolution();
434 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 447 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
435 448
436 if ( m_embedix ) 449 if ( m_embedix )
437 { 450 {
438 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 451 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
439 if ( fd ) 452 if ( fd )
440 { 453 {
441 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 454 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
442 ::close( fd ); 455 ::close( fd );
443 } 456 }
444 } 457 }
445 else 458 else
446 { 459 {
447 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); 460 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
448 if ( fd ) 461 if ( fd )
449 { 462 {
450 char buf[100]; 463 char buf[100];
451 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 464 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
452 res = ( ::write( fd, &buf[0], len ) == 0 ); 465 res = ( ::write( fd, &buf[0], len ) == 0 );
453 ::close( fd ); 466 ::close( fd );
454 } 467 }
455 } 468 }
456 return res; 469 return res;
457} 470}
458 471
459bool Zaurus::setDisplayStatus( bool on ) 472bool Zaurus::setDisplayStatus( bool on )
460{ 473{
461 bool res = false; 474 bool res = false;
462 if ( m_embedix ) 475 if ( m_embedix )
463 { 476 {
464 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 477 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
465 if ( fd ) 478 if ( fd )
466 { 479 {
467 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 480 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
468 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 481 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
469 ::close ( fd ); 482 ::close ( fd );
470 } 483 }
471 } 484 }
472 else 485 else
473 { 486 {
474 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); 487 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
475 if ( fd ) 488 if ( fd )
476 { 489 {
477 char buf[10]; 490 char buf[10];
478 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 491 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
479 buf[1] = '\0'; 492 buf[1] = '\0';
480 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 493 res = ( ::write( fd, &buf[0], 2 ) == 0 );
481 ::close( fd ); 494 ::close( fd );
482 } 495 }
483 } 496 }
484 return res; 497 return res;
485} 498}
486 499
487Transformation Zaurus::rotation() const 500Transformation Zaurus::rotation() const
488{ 501{
489 qDebug( "Zaurus::rotation()" ); 502 qDebug( "Zaurus::rotation()" );
490 Transformation rot; 503 Transformation rot;
491 504
492 switch ( d->m_model ) { 505 switch ( d->m_model ) {
493 case Model_Zaurus_SLC3000: // fallthrough 506 case Model_Zaurus_SLC3000: // fallthrough
494 case Model_Zaurus_SLC1000: // fallthrough 507 case Model_Zaurus_SLC1000: // fallthrough
495 case Model_Zaurus_SLC7x0: 508 case Model_Zaurus_SLC7x0:
496 { 509 {
497 OHingeStatus hs = readHingeSensor(); 510 OHingeStatus hs = readHingeSensor();
498 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); 511 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
499 512
500 if ( m_embedix ) 513 if ( m_embedix )
501 { 514 {
502 if ( hs == CASE_PORTRAIT ) rot = Rot0; 515 if ( hs == CASE_PORTRAIT ) rot = Rot0;
503 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 516 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
504 else rot = Rot270; 517 else rot = Rot270;
505 } 518 }
506 else 519 else
507 { 520 {
508 if ( hs == CASE_PORTRAIT ) rot = Rot90; 521 if ( hs == CASE_PORTRAIT ) rot = Rot90;
509 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 522 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
510 else rot = Rot0; 523 else rot = Rot0;
511 } 524 }
512 } 525 }
513 break; 526 break;
514 case Model_Zaurus_SL6000: 527 case Model_Zaurus_SL6000:
515 case Model_Zaurus_SLB600: 528 case Model_Zaurus_SLB600:
516 case Model_Zaurus_SLA300: 529 case Model_Zaurus_SLA300:
517 case Model_Zaurus_SL5500: 530 case Model_Zaurus_SL5500:
518 case Model_Zaurus_SL5000: 531 case Model_Zaurus_SL5000:
519 default: 532 default:
520 rot = d->m_rotation; 533 rot = d->m_rotation;
521 break; 534 break;
522 } 535 }
523 536
524 return rot; 537 return rot;
525} 538}
526ODirection Zaurus::direction() const 539ODirection Zaurus::direction() const
527{ 540{
528 ODirection dir; 541 ODirection dir;
529 542
530 switch ( d->m_model ) { 543 switch ( d->m_model ) {
531 case Model_Zaurus_SLC3000: // fallthrough 544 case Model_Zaurus_SLC3000: // fallthrough
532 case Model_Zaurus_SLC1000: // fallthrough 545 case Model_Zaurus_SLC1000: // fallthrough
533 case Model_Zaurus_SLC7x0: { 546 case Model_Zaurus_SLC7x0: {
534 OHingeStatus hs = readHingeSensor(); 547 OHingeStatus hs = readHingeSensor();
535 if ( hs == CASE_PORTRAIT ) dir = CCW; 548 if ( hs == CASE_PORTRAIT ) dir = CCW;
536 else if ( hs == CASE_UNKNOWN ) dir = CCW; 549 else if ( hs == CASE_UNKNOWN ) dir = CCW;
537 else dir = CW; 550 else dir = CW;
538 } 551 }
539 break; 552 break;
540 case Model_Zaurus_SL6000: 553 case Model_Zaurus_SL6000:
541 case Model_Zaurus_SLA300: 554 case Model_Zaurus_SLA300:
542 case Model_Zaurus_SLB600: 555 case Model_Zaurus_SLB600:
543 case Model_Zaurus_SL5500: 556 case Model_Zaurus_SL5500:
544 case Model_Zaurus_SL5000: 557 case Model_Zaurus_SL5000:
545 default: dir = d->m_direction; 558 default: dir = d->m_direction;
546 break; 559 break;
547 } 560 }
548 return dir; 561 return dir;
549 562
550} 563}
551 564
552bool Zaurus::hasHingeSensor() const 565bool Zaurus::hasHingeSensor() const
553{ 566{
554 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000; 567 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000;
555} 568}
556 569
557OHingeStatus Zaurus::readHingeSensor() const 570OHingeStatus Zaurus::readHingeSensor() const
558{ 571{
559 if (m_embedix) 572 if (m_embedix)
560 { 573 {
561 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 574 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
562 if (handle == -1) 575 if (handle == -1)
563 { 576 {
564 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 577 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
565 return CASE_UNKNOWN; 578 return CASE_UNKNOWN;
566 } 579 }
567 else 580 else
568 { 581 {
569 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 582 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
570 ::close (handle); 583 ::close (handle);
571 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 584 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
572 { 585 {
573 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 586 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
574 return static_cast<OHingeStatus>( retval ); 587 return static_cast<OHingeStatus>( retval );
575 } 588 }
576 else 589 else
577 { 590 {
578 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 591 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
579 return CASE_UNKNOWN; 592 return CASE_UNKNOWN;
580 } 593 }
581 } 594 }
582 } 595 }
583 else 596 else
584 { 597 {
585 // corgi keyboard is event source 0 in OZ kernel 2.6 598 // corgi keyboard is event source 0 in OZ kernel 2.6
586 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); 599 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" );
587 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; 600 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE;
588 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; 601 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT;
589 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; 602 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED;
590 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 603 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
591 return CASE_UNKNOWN; 604 return CASE_UNKNOWN;
592 } 605 }
593} 606}
594 607
595/* 608/*
596 * Take code from iPAQ device. 609 * Take code from iPAQ device.
597 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. 610 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction.
598 * I hope that is ok - Alwin 611 * I hope that is ok - Alwin
599 */ 612 */
600bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 613bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
601{ 614{
602 int newkeycode = keycode; 615 int newkeycode = keycode;
603 616
604 if (d->m_model != Model_Zaurus_SLC7x0 && d->m_model != Model_Zaurus_SLC3000 && d->m_model != Model_Zaurus_SLC1000) return false; 617 if (d->m_model != Model_Zaurus_SLC7x0 && d->m_model != Model_Zaurus_SLC3000 && d->m_model != Model_Zaurus_SLC1000) return false;
605 618
606 /* map cursor keys depending on the hinge status */ 619 /* map cursor keys depending on the hinge status */
607 switch ( keycode ) { 620 switch ( keycode ) {
608 // Rotate cursor keys 621 // Rotate cursor keys
609 case Key_Left : 622 case Key_Left :
610 case Key_Right: 623 case Key_Right:
611 case Key_Up : 624 case Key_Up :
612 case Key_Down : 625 case Key_Down :
613 { 626 {
614 if (rotation()==Rot90) { 627 if (rotation()==Rot90) {
615 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 628 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
616 } 629 }
617 } 630 }
618 break; 631 break;
619 632
620 } 633 }
621 if (newkeycode!=keycode) { 634 if (newkeycode!=keycode) {
622 if ( newkeycode != Key_unknown ) { 635 if ( newkeycode != Key_unknown ) {
623 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 636 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
624 } 637 }
625 return true; 638 return true;
626 } 639 }
627 return false; 640 return false;
628} 641}
629 642
630bool Zaurus::suspend() { 643bool Zaurus::suspend() {
631 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 644 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
632 return false; 645 return false;
633 646
634 bool res = false; 647 bool res = false;
635 OAbstractMobileDevice::sendSuspendmsg(); 648 OAbstractMobileDevice::sendSuspendmsg();
636 649
637 struct timeval tvs, tvn; 650 struct timeval tvs, tvn;
638 ::gettimeofday ( &tvs, 0 ); 651 ::gettimeofday ( &tvs, 0 );
639 652
640 ::sync(); // flush fs caches 653 ::sync(); // flush fs caches
641 res = ( ::system ( "apm --suspend" ) == 0 ); 654 res = ( ::system ( "apm --suspend" ) == 0 );
642 655
643 // This is needed because some apm implementations are asynchronous and we 656 // This is needed because some apm implementations are asynchronous and we
644 // can not be sure when exactly the device is really suspended 657 // can not be sure when exactly the device is really suspended
645 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 658 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
646 // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. 659 // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here.
647 660
648 if ( res && m_embedix) { 661 if ( res && m_embedix) {
649 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 662 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
650 ::usleep ( 200 * 1000 ); 663 ::usleep ( 200 * 1000 );
651 ::gettimeofday ( &tvn, 0 ); 664 ::gettimeofday ( &tvn, 0 );
652 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); 665 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut );
653 } 666 }
654 667
655 return res; 668 return res;
656} 669}
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index 4250356..4314aff 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,144 +1,145 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2002-2005 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; version 2 of the License.
12     ._= =}       : or (at your option) any later version. 12     ._= =}       :
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_ZAURUS 30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS 31#define ODEVICE_ZAURUS
32 32
33#include "odevice_abstractmobiledevice.h" 33#include "odevice_abstractmobiledevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38#ifndef ARRAY_SIZE 38#ifndef ARRAY_SIZE
39#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 39#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
40#endif 40#endif
41 41
42// _IO and friends are only defined in kernel headers ... 42// _IO and friends are only defined in kernel headers ...
43#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 43#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
44#define OD_IO(type,number) OD_IOC(0,type,number,0) 44#define OD_IO(type,number) OD_IOC(0,type,number,0)
45#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 45#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
46#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 46#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
47#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 47#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
48 48
49// Audio 49// Audio
50#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 50#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
51 51
52#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 52#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
53#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 53#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
54 54
55#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 55#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
56#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 56#define SHARP_BUZ_KEYSOUND 2 /* key sound */
57#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 57#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
58 58
59#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 59#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
60#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 60#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
61#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 61#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
62#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 62#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
63#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 63#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
64 64
65// LED 65// LED
66#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 66#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
67#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 67#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
68#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 68#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
69 69
70#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 70#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
71#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 71#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
72#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 72#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
73 73
74// Rotation and Power Management 74// Rotation and Power Management
75#define SHARP_IOCTL_GET_ROTATION 0x413c 75#define SHARP_IOCTL_GET_ROTATION 0x413c
76 76
77#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 77#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
78#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 78#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
79#define APM_EVT_POWER_BUTTON (1 << 0) 79#define APM_EVT_POWER_BUTTON (1 << 0)
80 80
81// Brightness Embedix 81// Brightness Embedix
82#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" 82#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl"
83#define SHARP_FL_IOCTL_ON 1 83#define SHARP_FL_IOCTL_ON 1
84#define SHARP_FL_IOCTL_OFF 2 84#define SHARP_FL_IOCTL_OFF 2
85#define SHARP_FL_IOCTL_STEP_CONTRAST 100 85#define SHARP_FL_IOCTL_STEP_CONTRAST 100
86#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 86#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
87#define SHARP_FL_IOCTL_GET_STEP 102 87#define SHARP_FL_IOCTL_GET_STEP 102
88 88
89// Vesa Standard 89// Vesa Standard
90#define FB_BLANK_UNBLANK 0 90#define FB_BLANK_UNBLANK 0
91#define FB_BLANK_POWERDOWN 4 91#define FB_BLANK_POWERDOWN 4
92 92
93namespace Opie { 93namespace Opie {
94namespace Core { 94namespace Core {
95namespace Internal { 95namespace Internal {
96 96
97class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter 97class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
98{ 98{
99 protected: 99 protected:
100 virtual void init(const QString&); 100 virtual void init(const QString&);
101 virtual void initButtons(); 101 virtual void initButtons();
102 102
103 public: 103 public:
104 virtual bool setDisplayBrightness( int b ); 104 virtual bool setDisplayBrightness( int b );
105 virtual bool setDisplayStatus( bool on ); 105 virtual bool setDisplayStatus( bool on );
106 virtual int displayBrightnessResolution() const; 106 virtual int displayBrightnessResolution() const;
107 107
108 virtual void playAlarmSound(); 108 virtual void playAlarmSound();
109 virtual void playKeySound(); 109 virtual void playKeySound();
110 virtual void playTouchSound(); 110 virtual void playTouchSound();
111 111
112 virtual QValueList <OLed> ledList() const; 112 virtual QValueList <OLed> ledList() const;
113 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 113 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
114 virtual OLedState ledState( OLed led ) const; 114 virtual OLedState ledState( OLed led ) const;
115 virtual bool setLedState( OLed led, OLedState st ); 115 virtual bool setLedState( OLed led, OLedState st );
116 116
117 virtual bool hasHingeSensor() const; 117 virtual bool hasHingeSensor() const;
118 virtual OHingeStatus readHingeSensor() const; 118 virtual OHingeStatus readHingeSensor() const;
119 119
120 virtual Transformation rotation() const; 120 virtual Transformation rotation() const;
121 virtual ODirection direction() const; 121 virtual ODirection direction() const;
122 virtual bool suspend(); 122 virtual bool suspend();
123 123
124 protected: 124 protected:
125 virtual void buzzer( int snd ); 125 virtual void buzzer( int snd );
126 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 126 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
127 127
128 QString m_backlightdev;
128 OLedState m_leds[1]; 129 OLedState m_leds[1];
129 bool m_embedix; 130 bool m_embedix;
130}; 131};
131 132
132struct z_button { 133struct z_button {
133 Qt::Key code; 134 Qt::Key code;
134 char *utext; 135 char *utext;
135 char *pix; 136 char *pix;
136 char *fpressedservice; 137 char *fpressedservice;
137 char *fpressedaction; 138 char *fpressedaction;
138 char *fheldservice; 139 char *fheldservice;
139 char *fheldaction; 140 char *fheldaction;
140}; 141};
141} 142}
142} 143}
143} 144}
144#endif 145#endif