summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 59f1592..780d130 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,589 +1,593 @@
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 =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 4 =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
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::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
61 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
65 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
69 "devicebuttons/z_home", 69 "devicebuttons/z_home",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
73 "devicebuttons/z_menu", 73 "devicebuttons/z_menu",
74 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
77 "devicebuttons/z_mail", 77 "devicebuttons/z_mail",
78 "opiemail", "raise()", 78 "opiemail", "raise()",
79 "opiemail", "newMail()" }, 79 "opiemail", "newMail()" },
80}; 80};
81 81
82struct z_button z_buttons_c700 [] = { 82struct z_button z_buttons_c700 [] = {
83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
84 "devicebuttons/z_calendar", 84 "devicebuttons/z_calendar",
85 "datebook", "nextView()", 85 "datebook", "nextView()",
86 "today", "raise()" }, 86 "today", "raise()" },
87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/z_contact", 88 "devicebuttons/z_contact",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
92 "devicebuttons/z_home", 92 "devicebuttons/z_home",
93 "QPE/Launcher", "home()", 93 "QPE/Launcher", "home()",
94 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
96 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
97 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
98 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
99 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
100 "devicebuttons/z_mail",
101 "opiemail", "raise()",
102 "opiemail", "newMail()" },
99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 103 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
100 "devicebuttons/z_hinge", 104 "devicebuttons/z_hinge",
101 "QPE/Rotation", "rotateDefault()", 105 "QPE/Rotation", "rotateDefault()",
102 "QPE/Dummy", "doNothing()" }, 106 "QPE/Dummy", "doNothing()" },
103}; 107};
104 108
105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 109// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
106// class up into individual classes. We need three classes 110// class up into individual classes. We need three classes
107// 111//
108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 112// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 113// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) 114// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000)
111// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) 115// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
112// 116//
113// Only question right now is: Do we really need to do it? Because as soon 117// Only question right now is: Do we really need to do it? Because as soon
114// as the OpenZaurus kernel is ready, there will be a unified interface for all 118// as the OpenZaurus kernel is ready, there will be a unified interface for all
115// Zaurus models (concerning apm, backlight, buttons, etc.) 119// Zaurus models (concerning apm, backlight, buttons, etc.)
116// 120//
117// Comments? - mickeyl. 121// Comments? - mickeyl.
118 122
119void Zaurus::init(const QString& cpu_info) 123void Zaurus::init(const QString& cpu_info)
120{ 124{
121 // generic distribution code already scanned /etc/issue at that point - 125 // generic distribution code already scanned /etc/issue at that point -
122 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 126 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
123 if ( d->m_sysverstr.contains( "embedix", false ) ) 127 if ( d->m_sysverstr.contains( "embedix", false ) )
124 { 128 {
125 d->m_vendorstr = "Sharp"; 129 d->m_vendorstr = "Sharp";
126 d->m_vendor = Vendor_Sharp; 130 d->m_vendor = Vendor_Sharp;
127 d->m_systemstr = "Zaurus"; 131 d->m_systemstr = "Zaurus";
128 d->m_system = System_Zaurus; 132 d->m_system = System_Zaurus;
129 m_embedix = true; 133 m_embedix = true;
130 } 134 }
131 else 135 else
132 { 136 {
133 d->m_vendorstr = "OpenZaurus Team"; 137 d->m_vendorstr = "OpenZaurus Team";
134 d->m_systemstr = "OpenZaurus"; 138 d->m_systemstr = "OpenZaurus";
135 d->m_system = System_OpenZaurus; 139 d->m_system = System_OpenZaurus;
136 // sysver already gathered 140 // sysver already gathered
137 141
138 // OpenZaurus sometimes uses the embedix kernel, check if this is one 142 // OpenZaurus sometimes uses the embedix kernel, check if this is one
139 FILE *uname = popen("uname -r", "r"); 143 FILE *uname = popen("uname -r", "r");
140 QFile f; 144 QFile f;
141 QString line; 145 QString line;
142 if ( f.open(IO_ReadOnly, uname) ) { 146 if ( f.open(IO_ReadOnly, uname) ) {
143 QTextStream ts ( &f ); 147 QTextStream ts ( &f );
144 line = ts. readLine(); 148 line = ts. readLine();
145 int loc = line. find ( "embedix" ); 149 int loc = line. find ( "embedix" );
146 if ( loc != -1 ) 150 if ( loc != -1 )
147 m_embedix = true; 151 m_embedix = true;
148 else 152 else
149 m_embedix = false; 153 m_embedix = false;
150 f.close(); 154 f.close();
151 } 155 }
152 pclose(uname); 156 pclose(uname);
153 } 157 }
154 158
155 // check the Zaurus model 159 // check the Zaurus model
156 QString model; 160 QString model;
157 int loc = cpu_info.find( ":" ); 161 int loc = cpu_info.find( ":" );
158 if ( loc != -1 ) 162 if ( loc != -1 )
159 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 163 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
160 else 164 else
161 model = cpu_info; 165 model = cpu_info;
162 166
163 if ( model == "SHARP Corgi" ) { 167 if ( model == "SHARP Corgi" ) {
164 d->m_model = Model_Zaurus_SLC7x0; 168 d->m_model = Model_Zaurus_SLC7x0;
165 d->m_modelstr = "Zaurus SL-C700"; 169 d->m_modelstr = "Zaurus SL-C700";
166 } else if ( model == "SHARP Shepherd" ) { 170 } else if ( model == "SHARP Shepherd" ) {
167 d->m_model = Model_Zaurus_SLC7x0; 171 d->m_model = Model_Zaurus_SLC7x0;
168 d->m_modelstr = "Zaurus SL-C750"; 172 d->m_modelstr = "Zaurus SL-C750";
169 } else if ( model == "SHARP Husky" ) { 173 } else if ( model == "SHARP Husky" ) {
170 d->m_model = Model_Zaurus_SLC7x0; 174 d->m_model = Model_Zaurus_SLC7x0;
171 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 175 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
172 } else if ( model == "SHARP Boxer" ) { 176 } else if ( model == "SHARP Boxer" ) {
173 d->m_model = Model_Zaurus_SLC7x0; 177 d->m_model = Model_Zaurus_SLC7x0;
174 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 178 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
175 } else if ( model == "SHARP Poodle" ) { 179 } else if ( model == "SHARP Poodle" ) {
176 d->m_model = Model_Zaurus_SLB600; 180 d->m_model = Model_Zaurus_SLB600;
177 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 181 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
178 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 182 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
179 d->m_model = Model_Zaurus_SL5500; 183 d->m_model = Model_Zaurus_SL5500;
180 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 184 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
181 } else if ( model == "SHARP Tosa" ) { 185 } else if ( model == "SHARP Tosa" ) {
182 d->m_model = Model_Zaurus_SL6000; 186 d->m_model = Model_Zaurus_SL6000;
183 d->m_modelstr = "Zaurus SL-6000"; 187 d->m_modelstr = "Zaurus SL-6000";
184 } else if ( model == "SHARP Spitz" ) { 188 } else if ( model == "SHARP Spitz" ) {
185 d->m_model = Model_Zaurus_SLC3000; 189 d->m_model = Model_Zaurus_SLC3000;
186 d->m_modelstr = "Zaurus SL-C3000"; 190 d->m_modelstr = "Zaurus SL-C3000";
187 } else { 191 } else {
188 d->m_model = Model_Zaurus_SL5500; 192 d->m_model = Model_Zaurus_SL5500;
189 d->m_modelstr = "Unknown Zaurus"; 193 d->m_modelstr = "Unknown Zaurus";
190 } 194 }
191 195
192 // set initial rotation 196 // set initial rotation
193 switch( d->m_model ) { 197 switch( d->m_model ) {
194 case Model_Zaurus_SL6000: // fallthrough 198 case Model_Zaurus_SL6000: // fallthrough
195 case Model_Zaurus_SLA300: 199 case Model_Zaurus_SLA300:
196 d->m_rotation = Rot0; 200 d->m_rotation = Rot0;
197 break; 201 break;
198 case Model_Zaurus_SLC3000: // fallthrough 202 case Model_Zaurus_SLC3000: // fallthrough
199 case Model_Zaurus_SLC7x0: 203 case Model_Zaurus_SLC7x0:
200 d->m_rotation = rotation(); 204 d->m_rotation = rotation();
201 d->m_direction = direction(); 205 d->m_direction = direction();
202 break; 206 break;
203 case Model_Zaurus_SLB600: // fallthrough 207 case Model_Zaurus_SLB600: // fallthrough
204 case Model_Zaurus_SL5000: // fallthrough 208 case Model_Zaurus_SL5000: // fallthrough
205 case Model_Zaurus_SL5500: // fallthrough 209 case Model_Zaurus_SL5500: // fallthrough
206 default: 210 default:
207 d->m_rotation = Rot270; 211 d->m_rotation = Rot270;
208 break; 212 break;
209 } 213 }
210 m_leds[0] = Led_Off; 214 m_leds[0] = Led_Off;
211 215
212 if ( m_embedix ) 216 if ( m_embedix )
213 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); 217 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr );
214 else 218 else
215 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 219 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
216} 220}
217 221
218void Zaurus::initButtons() 222void Zaurus::initButtons()
219{ 223{
220 if ( d->m_buttons ) 224 if ( d->m_buttons )
221 return; 225 return;
222 226
223 d->m_buttons = new QValueList <ODeviceButton>; 227 d->m_buttons = new QValueList <ODeviceButton>;
224 228
225 struct z_button * pz_buttons; 229 struct z_button * pz_buttons;
226 int buttoncount; 230 int buttoncount;
227 switch ( d->m_model ) { 231 switch ( d->m_model ) {
228 case Model_Zaurus_SLC3000: // fallthrough 232 case Model_Zaurus_SLC3000: // fallthrough
229 case Model_Zaurus_SLC7x0: 233 case Model_Zaurus_SLC7x0:
230 pz_buttons = z_buttons_c700; 234 pz_buttons = z_buttons_c700;
231 buttoncount = ARRAY_SIZE(z_buttons_c700); 235 buttoncount = ARRAY_SIZE(z_buttons_c700);
232 break; 236 break;
233 default: 237 default:
234 pz_buttons = z_buttons; 238 pz_buttons = z_buttons;
235 buttoncount = ARRAY_SIZE(z_buttons); 239 buttoncount = ARRAY_SIZE(z_buttons);
236 break; 240 break;
237 } 241 }
238 242
239 for ( int i = 0; i < buttoncount; i++ ) { 243 for ( int i = 0; i < buttoncount; i++ ) {
240 struct z_button *zb = pz_buttons + i; 244 struct z_button *zb = pz_buttons + i;
241 ODeviceButton b; 245 ODeviceButton b;
242 246
243 b.setKeycode( zb->code ); 247 b.setKeycode( zb->code );
244 b.setUserText( QObject::tr( "Button", zb->utext )); 248 b.setUserText( QObject::tr( "Button", zb->utext ));
245 b.setPixmap( Resource::loadPixmap( zb->pix )); 249 b.setPixmap( Resource::loadPixmap( zb->pix ));
246 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 250 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
247 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 251 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
248 d->m_buttons->append( b ); 252 d->m_buttons->append( b );
249 } 253 }
250 254
251 reloadButtonMapping(); 255 reloadButtonMapping();
252} 256}
253 257
254 258
255 259
256typedef struct sharp_led_status { 260typedef struct sharp_led_status {
257 int which; /* select which LED status is wanted. */ 261 int which; /* select which LED status is wanted. */
258 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 262 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
259} sharp_led_status; 263} sharp_led_status;
260 264
261void Zaurus::buzzer( int sound ) 265void Zaurus::buzzer( int sound )
262{ 266{
263#ifndef QT_NO_SOUND 267#ifndef QT_NO_SOUND
264 Sound *snd = 0; 268 Sound *snd = 0;
265 269
266 // All devices except SL5500 have a DSP device 270 // All devices except SL5500 have a DSP device
267 if ( d->m_model != Model_Zaurus_SL5000 271 if ( d->m_model != Model_Zaurus_SL5000
268 && d->m_model != Model_Zaurus_SL5500 ) { 272 && d->m_model != Model_Zaurus_SL5500 ) {
269 273
270 switch ( sound ){ 274 switch ( sound ){
271 case SHARP_BUZ_TOUCHSOUND: { 275 case SHARP_BUZ_TOUCHSOUND: {
272 static Sound touch_sound("touchsound"); 276 static Sound touch_sound("touchsound");
273 snd = &touch_sound; 277 snd = &touch_sound;
274 } 278 }
275 break; 279 break;
276 case SHARP_BUZ_KEYSOUND: { 280 case SHARP_BUZ_KEYSOUND: {
277 static Sound key_sound( "keysound" ); 281 static Sound key_sound( "keysound" );
278 snd = &key_sound; 282 snd = &key_sound;
279 } 283 }
280 break; 284 break;
281 case SHARP_BUZ_SCHEDULE_ALARM: 285 case SHARP_BUZ_SCHEDULE_ALARM:
282 default: { 286 default: {
283 static Sound alarm_sound("alarm"); 287 static Sound alarm_sound("alarm");
284 snd = &alarm_sound; 288 snd = &alarm_sound;
285 } 289 }
286 break; 290 break;
287 } 291 }
288 } 292 }
289 293
290 // If a soundname is defined, we expect that this device has 294 // If a soundname is defined, we expect that this device has
291 // sound capabilities.. Otherwise we expect to have the buzzer 295 // sound capabilities.. Otherwise we expect to have the buzzer
292 // device.. 296 // device..
293 if ( snd && snd->isFinished() ){ 297 if ( snd && snd->isFinished() ){
294 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 298 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
295 snd->play(); 299 snd->play();
296 } else if( !snd ) { 300 } else if( !snd ) {
297 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 301 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
298 302
299 if ( fd >= 0 ) { 303 if ( fd >= 0 ) {
300 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 304 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
301 ::close ( fd ); 305 ::close ( fd );
302 } 306 }
303 307
304 } 308 }
305#endif 309#endif
306} 310}
307 311
308 312
309void Zaurus::playAlarmSound() 313void Zaurus::playAlarmSound()
310{ 314{
311 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 315 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
312} 316}
313 317
314void Zaurus::playTouchSound() 318void Zaurus::playTouchSound()
315{ 319{
316 buzzer( SHARP_BUZ_TOUCHSOUND ); 320 buzzer( SHARP_BUZ_TOUCHSOUND );
317} 321}
318 322
319void Zaurus::playKeySound() 323void Zaurus::playKeySound()
320{ 324{
321 buzzer( SHARP_BUZ_KEYSOUND ); 325 buzzer( SHARP_BUZ_KEYSOUND );
322} 326}
323 327
324 328
325QValueList <OLed> Zaurus::ledList() const 329QValueList <OLed> Zaurus::ledList() const
326{ 330{
327 QValueList <OLed> vl; 331 QValueList <OLed> vl;
328 vl << Led_Mail; 332 vl << Led_Mail;
329 return vl; 333 return vl;
330} 334}
331 335
332QValueList <OLedState> Zaurus::ledStateList( OLed l ) const 336QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
333{ 337{
334 QValueList <OLedState> vl; 338 QValueList <OLedState> vl;
335 339
336 if ( l == Led_Mail ) 340 if ( l == Led_Mail )
337 vl << Led_Off << Led_On << Led_BlinkSlow; 341 vl << Led_Off << Led_On << Led_BlinkSlow;
338 return vl; 342 return vl;
339} 343}
340 344
341OLedState Zaurus::ledState( OLed which ) const 345OLedState Zaurus::ledState( OLed which ) const
342{ 346{
343 if ( which == Led_Mail ) 347 if ( which == Led_Mail )
344 return m_leds [0]; 348 return m_leds [0];
345 else 349 else
346 return Led_Off; 350 return Led_Off;
347} 351}
348 352
349bool Zaurus::setLedState( OLed which, OLedState st ) 353bool Zaurus::setLedState( OLed which, OLedState st )
350{ 354{
351 // Currently not supported on non_embedix kernels 355 // Currently not supported on non_embedix kernels
352 if (!m_embedix) 356 if (!m_embedix)
353 { 357 {
354 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); 358 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
355 return false; 359 return false;
356 } 360 }
357 361
358 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 362 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
359 363
360 if ( which == Led_Mail ) { 364 if ( which == Led_Mail ) {
361 if ( fd >= 0 ) { 365 if ( fd >= 0 ) {
362 struct sharp_led_status leds; 366 struct sharp_led_status leds;
363 ::memset ( &leds, 0, sizeof( leds )); 367 ::memset ( &leds, 0, sizeof( leds ));
364 leds. which = SHARP_LED_MAIL_EXISTS; 368 leds. which = SHARP_LED_MAIL_EXISTS;
365 bool ok = true; 369 bool ok = true;
366 370
367 switch ( st ) { 371 switch ( st ) {
368 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 372 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
369 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 373 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
370 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 374 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
371 default : ok = false; 375 default : ok = false;
372 } 376 }
373 377
374 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 378 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
375 m_leds [0] = st; 379 m_leds [0] = st;
376 return true; 380 return true;
377 } 381 }
378 } 382 }
379 } 383 }
380 return false; 384 return false;
381} 385}
382 386
383int Zaurus::displayBrightnessResolution() const 387int Zaurus::displayBrightnessResolution() const
384{ 388{
385 int res = 1; 389 int res = 1;
386 if (m_embedix) 390 if (m_embedix)
387 { 391 {
388 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 392 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
389 if ( fd ) 393 if ( fd )
390 { 394 {
391 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); 395 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
392 ::close( fd ); 396 ::close( fd );
393 return value ? value : res; 397 return value ? value : res;
394 } 398 }
395 } 399 }
396 else 400 else
397 { 401 {
398 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); 402 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK );
399 if ( fd ) 403 if ( fd )
400 { 404 {
401 char buf[100]; 405 char buf[100];
402 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 406 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
403 ::close( fd ); 407 ::close( fd );
404 } 408 }
405 } 409 }
406 return res; 410 return res;
407} 411}
408 412
409bool Zaurus::setDisplayBrightness( int bright ) 413bool Zaurus::setDisplayBrightness( int bright )
410{ 414{
411 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 415 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
412 bool res = false; 416 bool res = false;
413 417
414 if ( bright > 255 ) bright = 255; 418 if ( bright > 255 ) bright = 255;
415 if ( bright < 0 ) bright = 0; 419 if ( bright < 0 ) bright = 0;
416 420
417 int numberOfSteps = displayBrightnessResolution(); 421 int numberOfSteps = displayBrightnessResolution();
418 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 422 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
419 423
420 if ( m_embedix ) 424 if ( m_embedix )
421 { 425 {
422 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 426 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
423 if ( fd ) 427 if ( fd )
424 { 428 {
425 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 429 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
426 ::close( fd ); 430 ::close( fd );
427 } 431 }
428 } 432 }
429 else 433 else
430 { 434 {
431 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); 435 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK );
432 if ( fd ) 436 if ( fd )
433 { 437 {
434 char buf[100]; 438 char buf[100];
435 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 439 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
436 res = ( ::write( fd, &buf[0], len ) == 0 ); 440 res = ( ::write( fd, &buf[0], len ) == 0 );
437 ::close( fd ); 441 ::close( fd );
438 } 442 }
439 } 443 }
440 return res; 444 return res;
441} 445}
442 446
443bool Zaurus::setDisplayStatus( bool on ) 447bool Zaurus::setDisplayStatus( bool on )
444{ 448{
445 bool res = false; 449 bool res = false;
446 if ( m_embedix ) 450 if ( m_embedix )
447 { 451 {
448 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 452 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
449 if ( fd ) 453 if ( fd )
450 { 454 {
451 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 455 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
452 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 456 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
453 ::close ( fd ); 457 ::close ( fd );
454 } 458 }
455 } 459 }
456 else 460 else
457 { 461 {
458 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); 462 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
459 if ( fd ) 463 if ( fd )
460 { 464 {
461 char buf[10]; 465 char buf[10];
462 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 466 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
463 buf[1] = '\0'; 467 buf[1] = '\0';
464 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 468 res = ( ::write( fd, &buf[0], 2 ) == 0 );
465 ::close( fd ); 469 ::close( fd );
466 } 470 }
467 } 471 }
468 return res; 472 return res;
469} 473}
470 474
471bool Zaurus::suspend() 475bool Zaurus::suspend()
472{ 476{
473 qDebug("ODevice::suspend"); 477 qDebug("ODevice::suspend");
474 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 478 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
475 return false; 479 return false;
476 480
477 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 481 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
478 return false; 482 return false;
479 483
480 bool res = false; 484 bool res = false;
481 ODevice::sendSuspendmsg(); 485 ODevice::sendSuspendmsg();
482 486
483 struct timeval tvs, tvn; 487 struct timeval tvs, tvn;
484 ::gettimeofday ( &tvs, 0 ); 488 ::gettimeofday ( &tvs, 0 );
485 489
486 ::sync(); // flush fs caches 490 ::sync(); // flush fs caches
487 res = ( ::system ( "apm --suspend" ) == 0 ); 491 res = ( ::system ( "apm --suspend" ) == 0 );
488 492
489 // This is needed because the apm implementation is asynchronous and we 493 // This is needed because the apm implementation is asynchronous and we
490 // can not be sure when exactly the device is really suspended 494 // can not be sure when exactly the device is really suspended
491 if ( res ) { 495 if ( res ) {
492 do { // Yes, wait 15 seconds. This APM sucks big time. 496 do { // Yes, wait 15 seconds. This APM sucks big time.
493 ::usleep ( 200 * 1000 ); 497 ::usleep ( 200 * 1000 );
494 ::gettimeofday ( &tvn, 0 ); 498 ::gettimeofday ( &tvn, 0 );
495 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 499 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
496 } 500 }
497 501
498 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 502 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
499 return res; 503 return res;
500} 504}
501 505
502 506
503Transformation Zaurus::rotation() const 507Transformation Zaurus::rotation() const
504{ 508{
505 Transformation rot; 509 Transformation rot;
506 510
507 switch ( d->m_model ) { 511 switch ( d->m_model ) {
508 case Model_Zaurus_SLC3000: // fallthrough 512 case Model_Zaurus_SLC3000: // fallthrough
509 case Model_Zaurus_SLC7x0: { 513 case Model_Zaurus_SLC7x0: {
510 OHingeStatus hs = readHingeSensor(); 514 OHingeStatus hs = readHingeSensor();
511 if ( hs == CASE_PORTRAIT ) rot = Rot0; 515 if ( hs == CASE_PORTRAIT ) rot = Rot0;
512 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 516 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
513 else rot = Rot270; 517 else rot = Rot270;
514 } 518 }
515 break; 519 break;
516 case Model_Zaurus_SL6000: 520 case Model_Zaurus_SL6000:
517 case Model_Zaurus_SLB600: 521 case Model_Zaurus_SLB600:
518 case Model_Zaurus_SLA300: 522 case Model_Zaurus_SLA300:
519 case Model_Zaurus_SL5500: 523 case Model_Zaurus_SL5500:
520 case Model_Zaurus_SL5000: 524 case Model_Zaurus_SL5000:
521 default: 525 default:
522 rot = d->m_rotation; 526 rot = d->m_rotation;
523 break; 527 break;
524 } 528 }
525 529
526 return rot; 530 return rot;
527} 531}
528ODirection Zaurus::direction() const 532ODirection Zaurus::direction() const
529{ 533{
530 ODirection dir; 534 ODirection dir;
531 535
532 switch ( d->m_model ) { 536 switch ( d->m_model ) {
533 case Model_Zaurus_SLC3000: // fallthrough 537 case Model_Zaurus_SLC3000: // fallthrough
534 case Model_Zaurus_SLC7x0: { 538 case Model_Zaurus_SLC7x0: {
535 OHingeStatus hs = readHingeSensor(); 539 OHingeStatus hs = readHingeSensor();
536 if ( hs == CASE_PORTRAIT ) dir = CCW; 540 if ( hs == CASE_PORTRAIT ) dir = CCW;
537 else if ( hs == CASE_UNKNOWN ) dir = CCW; 541 else if ( hs == CASE_UNKNOWN ) dir = CCW;
538 else dir = CW; 542 else dir = CW;
539 } 543 }
540 break; 544 break;
541 case Model_Zaurus_SL6000: 545 case Model_Zaurus_SL6000:
542 case Model_Zaurus_SLA300: 546 case Model_Zaurus_SLA300:
543 case Model_Zaurus_SLB600: 547 case Model_Zaurus_SLB600:
544 case Model_Zaurus_SL5500: 548 case Model_Zaurus_SL5500:
545 case Model_Zaurus_SL5000: 549 case Model_Zaurus_SL5000:
546 default: dir = d->m_direction; 550 default: dir = d->m_direction;
547 break; 551 break;
548 } 552 }
549 return dir; 553 return dir;
550 554
551} 555}
552 556
553bool Zaurus::hasHingeSensor() const 557bool Zaurus::hasHingeSensor() const
554{ 558{
555 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; 559 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
556} 560}
557 561
558OHingeStatus Zaurus::readHingeSensor() const 562OHingeStatus Zaurus::readHingeSensor() const
559{ 563{
560 if (m_embedix) 564 if (m_embedix)
561 { 565 {
562 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 566 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
563 if (handle == -1) 567 if (handle == -1)
564 { 568 {
565 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 569 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
566 return CASE_UNKNOWN; 570 return CASE_UNKNOWN;
567 } 571 }
568 else 572 else
569 { 573 {
570 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 574 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
571 ::close (handle); 575 ::close (handle);
572 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 576 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
573 { 577 {
574 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 578 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
575 return static_cast<OHingeStatus>( retval ); 579 return static_cast<OHingeStatus>( retval );
576 } 580 }
577 else 581 else
578 { 582 {
579 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 583 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
580 return CASE_UNKNOWN; 584 return CASE_UNKNOWN;
581 } 585 }
582 } 586 }
583 } 587 }
584 else 588 else
585 { 589 {
586 qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" ); 590 qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" );
587 return CASE_UNKNOWN; 591 return CASE_UNKNOWN;
588 } 592 }
589} 593}