summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.h3
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp96
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h5
3 files changed, 64 insertions, 40 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 93d7d22..bbc32fa 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -59,48 +59,49 @@ enum OModel {
59 Model_Series_Mask = 0xff000000, 59 Model_Series_Mask = 0xff000000,
60 60
61 Model_iPAQ = ( 1 << 24 ), 61 Model_iPAQ = ( 1 << 24 ),
62 62
63 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 63 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), 69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ),
70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), 70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ),
71 71
72 Model_Jornada = ( 6 << 24 ), 72 Model_Jornada = ( 6 << 24 ),
73 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 73 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
74 74
75 Model_Zaurus = ( 2 << 24 ), 75 Model_Zaurus = ( 2 << 24 ),
76 76
77 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 77 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
78 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 78 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
79 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 79 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
80 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 80 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
81 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 81 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
82 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), 82 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ),
83 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x000007 ),
83 84
84 Model_SIMpad = ( 3 << 24 ), 85 Model_SIMpad = ( 3 << 24 ),
85 86
86 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 87 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
87 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 88 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
88 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 89 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
89 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 90 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
90 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 91 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
91 92
92 Model_Ramses = ( 4 << 24 ), 93 Model_Ramses = ( 4 << 24 ),
93 94
94 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 95 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
95 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 96 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
96 Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), 97 Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ),
97 98
98 Model_Yopy = ( 5 << 24 ), 99 Model_Yopy = ( 5 << 24 ),
99 100
100 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 101 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
101 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 102 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
102 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 103 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
103 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), 104 Model_Yopy_3700 = ( Model_Yopy | 0x000003 ),
104 105
105 Model_Beagle = ( 6 << 24 ), 106 Model_Beagle = ( 6 << 24 ),
106 107
@@ -340,40 +341,40 @@ protected:
340 /* ugly virtual hook */ 341 /* ugly virtual hook */
341 virtual void virtual_hook( int id, void* data ); 342 virtual void virtual_hook( int id, void* data );
342}; 343};
343 344
344class ODeviceData { 345class ODeviceData {
345 346
346 public: 347 public:
347 QString m_vendorstr; 348 QString m_vendorstr;
348 OVendor m_vendor; 349 OVendor m_vendor;
349 350
350 QString m_modelstr; 351 QString m_modelstr;
351 OModel m_model; 352 OModel m_model;
352 353
353 QString m_systemstr; 354 QString m_systemstr;
354 OSystem m_system; 355 OSystem m_system;
355 356
356 QString m_sysverstr; 357 QString m_sysverstr;
357 358
358 Transformation m_rotation; 359 Transformation m_rotation;
359 ODirection m_direction; 360 ODirection m_direction;
360 361
361 QValueList <ODeviceButton> *m_buttons; 362 QValueList <ODeviceButton> *m_buttons;
362 uint m_holdtime; 363 uint m_holdtime;
363 QStrList *m_cpu_frequencies; 364 QStrList *m_cpu_frequencies;
364 boolm_initializedButtonQcop : 1; 365 bool m_initializedButtonQcop : 1;
365 366
366 /* values for changeMixerForAlarm */ 367 /* values for changeMixerForAlarm */
367 int m_sound, m_vol, m_mixer; 368 int m_sound, m_vol, m_mixer;
368}; 369};
369 370
370extern bool isQWS(); 371extern bool isQWS();
371extern QCString makeChannel ( const char *str ); 372extern QCString makeChannel ( const char *str );
372} 373}
373} 374}
374 375
375 376
376 377
377 378
378#endif 379#endif
379 380
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index fb23e1d..75a2fdc 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -148,80 +148,87 @@ void Zaurus::init(const QString& cpu_info)
148 else 148 else
149 m_embedix = false; 149 m_embedix = false;
150 f.close(); 150 f.close();
151 } 151 }
152 pclose(uname); 152 pclose(uname);
153 } 153 }
154 154
155 // check the Zaurus model 155 // check the Zaurus model
156 QString model; 156 QString model;
157 int loc = cpu_info.find( ":" ); 157 int loc = cpu_info.find( ":" );
158 if ( loc != -1 ) 158 if ( loc != -1 )
159 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 159 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
160 else 160 else
161 model = cpu_info; 161 model = cpu_info;
162 162
163 if ( model == "SHARP Corgi" ) { 163 if ( model == "SHARP Corgi" ) {
164 d->m_model = Model_Zaurus_SLC7x0; 164 d->m_model = Model_Zaurus_SLC7x0;
165 d->m_modelstr = "Zaurus SL-C700"; 165 d->m_modelstr = "Zaurus SL-C700";
166 } else if ( model == "SHARP Shepherd" ) { 166 } else if ( model == "SHARP Shepherd" ) {
167 d->m_model = Model_Zaurus_SLC7x0; 167 d->m_model = Model_Zaurus_SLC7x0;
168 d->m_modelstr = "Zaurus SL-C750"; 168 d->m_modelstr = "Zaurus SL-C750";
169 } else if ( model == "SHARP Husky" ) { 169 } else if ( model == "SHARP Husky" ) {
170 d->m_model = Model_Zaurus_SLC7x0; 170 d->m_model = Model_Zaurus_SLC7x0;
171 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 171 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
172 } else if ( model == "SHARP Boxer" ) {
173 d->m_model = Model_Zaurus_SLC7x0;
174 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
172 } else if ( model == "SHARP Poodle" ) { 175 } else if ( model == "SHARP Poodle" ) {
173 d->m_model = Model_Zaurus_SLB600; 176 d->m_model = Model_Zaurus_SLB600;
174 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 177 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
175 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 178 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
176 d->m_model = Model_Zaurus_SL5500; 179 d->m_model = Model_Zaurus_SL5500;
177 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 180 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
178 } else if ( model == "SHARP Tosa" ) { 181 } else if ( model == "SHARP Tosa" ) {
179 d->m_model = Model_Zaurus_SL6000; 182 d->m_model = Model_Zaurus_SL6000;
180 d->m_modelstr = "Zaurus SL-6000"; 183 d->m_modelstr = "Zaurus SL-6000";
184 } else if ( model == "SHARP Spitz" ) {
185 d->m_model = Model_Zaurus_SLC3000;
186 d->m_modelstr = "Zaurus SL-C3000";
181 } else { 187 } else {
182 d->m_model = Model_Zaurus_SL5500; 188 d->m_model = Model_Zaurus_SL5500;
183 d->m_modelstr = "Unkown Zaurus"; 189 d->m_modelstr = "Unknown Zaurus";
184 } 190 }
185 191
186 // set initial rotation 192 // set initial rotation
187 switch( d->m_model ) { 193 switch( d->m_model ) {
188 case Model_Zaurus_SL6000: // fallthrough 194 case Model_Zaurus_SL6000: // fallthrough
189 case Model_Zaurus_SLA300: 195 case Model_Zaurus_SLA300:
190 d->m_rotation = Rot0; 196 d->m_rotation = Rot0;
191 break; 197 break;
198 case Model_Zaurus_SLC3000: // fallthrough
192 case Model_Zaurus_SLC7x0: 199 case Model_Zaurus_SLC7x0:
193 d->m_rotation = rotation(); 200 d->m_rotation = rotation();
194 d->m_direction = direction(); 201 d->m_direction = direction();
195 break; 202 break;
196 case Model_Zaurus_SLB600: // fallthrough 203 case Model_Zaurus_SLB600: // fallthrough
204 case Model_Zaurus_SL5000: // fallthrough
197 case Model_Zaurus_SL5500: // fallthrough 205 case Model_Zaurus_SL5500: // fallthrough
198 case Model_Zaurus_SL5000:
199 default: 206 default:
200 d->m_rotation = Rot270; 207 d->m_rotation = Rot270;
201 break; 208 break;
202 } 209 }
203 m_leds [0] = Led_Off; 210 m_leds[0] = Led_Off;
204} 211}
205 212
206void Zaurus::initButtons() 213void Zaurus::initButtons()
207{ 214{
208 if ( d->m_buttons ) 215 if ( d->m_buttons )
209 return; 216 return;
210 217
211 d->m_buttons = new QValueList <ODeviceButton>; 218 d->m_buttons = new QValueList <ODeviceButton>;
212 219
213 struct z_button * pz_buttons; 220 struct z_button * pz_buttons;
214 int buttoncount; 221 int buttoncount;
215 switch ( d->m_model ) { 222 switch ( d->m_model ) {
216 case Model_Zaurus_SLC7x0: 223 case Model_Zaurus_SLC7x0:
217 pz_buttons = z_buttons_c700; 224 pz_buttons = z_buttons_c700;
218 buttoncount = ARRAY_SIZE(z_buttons_c700); 225 buttoncount = ARRAY_SIZE(z_buttons_c700);
219 break; 226 break;
220 default: 227 default:
221 pz_buttons = z_buttons; 228 pz_buttons = z_buttons;
222 buttoncount = ARRAY_SIZE(z_buttons); 229 buttoncount = ARRAY_SIZE(z_buttons);
223 break; 230 break;
224 } 231 }
225 232
226 for ( int i = 0; i < buttoncount; i++ ) { 233 for ( int i = 0; i < buttoncount; i++ ) {
227 struct z_button *zb = pz_buttons + i; 234 struct z_button *zb = pz_buttons + i;
@@ -232,136 +239,139 @@ void Zaurus::initButtons()
232 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 239 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
233 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 240 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
234 zb->fpressedaction )); 241 zb->fpressedaction ));
235 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 242 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
236 zb->fheldaction )); 243 zb->fheldaction ));
237 244
238 d->m_buttons->append ( b ); 245 d->m_buttons->append ( b );
239 } 246 }
240 247
241 reloadButtonMapping(); 248 reloadButtonMapping();
242} 249}
243 250
244 251
245 252
246typedef struct sharp_led_status { 253typedef struct sharp_led_status {
247 int which; /* select which LED status is wanted. */ 254 int which; /* select which LED status is wanted. */
248 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 255 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
249} sharp_led_status; 256} sharp_led_status;
250 257
251void Zaurus::buzzer( int sound ) 258void Zaurus::buzzer( int sound )
252{ 259{
253#ifndef QT_NO_SOUND 260#ifndef QT_NO_SOUND
254 Sound *snd = 0; 261 Sound *snd = 0;
255 262
256 // Not all devices have real sound 263 // All devices except SL5500 have a DSP device
257 if ( d->m_model == Model_Zaurus_SLC7x0 264 if ( d->m_model != Model_Zaurus_SL5000
258 || d->m_model == Model_Zaurus_SLB600 265 && d->m_model != Model_Zaurus_SL5500 ) {
259 || d->m_model == Model_Zaurus_SL6000 ) {
260 266
261 switch ( sound ){ 267 switch ( sound ){
262 case SHARP_BUZ_TOUCHSOUND: { 268 case SHARP_BUZ_TOUCHSOUND: {
263 static Sound touch_sound("touchsound"); 269 static Sound touch_sound("touchsound");
264 snd = &touch_sound; 270 snd = &touch_sound;
265 } 271 }
266 break; 272 break;
267 case SHARP_BUZ_KEYSOUND: { 273 case SHARP_BUZ_KEYSOUND: {
268 static Sound key_sound( "keysound" ); 274 static Sound key_sound( "keysound" );
269 snd = &key_sound; 275 snd = &key_sound;
270 } 276 }
271 break; 277 break;
272 case SHARP_BUZ_SCHEDULE_ALARM: 278 case SHARP_BUZ_SCHEDULE_ALARM:
273 default: { 279 default: {
274 static Sound alarm_sound("alarm"); 280 static Sound alarm_sound("alarm");
275 snd = &alarm_sound; 281 snd = &alarm_sound;
276 } 282 }
277 break; 283 break;
278 } 284 }
279 } 285 }
280 286
281 // If a soundname is defined, we expect that this device has 287 // If a soundname is defined, we expect that this device has
282 // sound capabilities.. Otherwise we expect to have the buzzer 288 // sound capabilities.. Otherwise we expect to have the buzzer
283 // device.. 289 // device..
284 if ( snd && snd->isFinished() ){ 290 if ( snd && snd->isFinished() ){
285 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 291 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
286 snd->play(); 292 snd->play();
287 } else if( !snd ) { 293 } else if( !snd ) {
288 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 294 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
289 295
290 if ( fd >= 0 ) { 296 if ( fd >= 0 ) {
291 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 297 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
292 ::close ( fd ); 298 ::close ( fd );
293 } 299 }
294 300
295 } 301 }
296#endif 302#endif
297} 303}
298 304
299 305
300void Zaurus::playAlarmSound() 306void Zaurus::playAlarmSound()
301{ 307{
302 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 308 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
303} 309}
304 310
305void Zaurus::playTouchSound() 311void Zaurus::playTouchSound()
306{ 312{
307 buzzer( SHARP_BUZ_TOUCHSOUND ); 313 buzzer( SHARP_BUZ_TOUCHSOUND );
308} 314}
309 315
310void Zaurus::playKeySound() 316void Zaurus::playKeySound()
311{ 317{
312 buzzer( SHARP_BUZ_KEYSOUND ); 318 buzzer( SHARP_BUZ_KEYSOUND );
313} 319}
314 320
315 321
316QValueList <OLed> Zaurus::ledList() const 322QValueList <OLed> Zaurus::ledList() const
317{ 323{
318 QValueList <OLed> vl; 324 QValueList <OLed> vl;
319 vl << Led_Mail; 325 vl << Led_Mail;
320 return vl; 326 return vl;
321} 327}
322 328
323QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 329QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
324{ 330{
325 QValueList <OLedState> vl; 331 QValueList <OLedState> vl;
326 332
327 if ( l == Led_Mail ) 333 if ( l == Led_Mail )
328 vl << Led_Off << Led_On << Led_BlinkSlow; 334 vl << Led_Off << Led_On << Led_BlinkSlow;
329 return vl; 335 return vl;
330} 336}
331 337
332OLedState Zaurus::ledState ( OLed which ) const 338OLedState Zaurus::ledState( OLed which ) const
333{ 339{
334 if ( which == Led_Mail ) 340 if ( which == Led_Mail )
335 return m_leds [0]; 341 return m_leds [0];
336 else 342 else
337 return Led_Off; 343 return Led_Off;
338} 344}
339 345
340bool Zaurus::setLedState ( OLed which, OLedState st ) 346bool Zaurus::setLedState( OLed which, OLedState st )
341{ 347{
342 if (!m_embedix) // Currently not supported on non_embedix kernels 348 // Currently not supported on non_embedix kernels
349 if (!m_embedix)
350 {
351 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
343 return false; 352 return false;
353 }
344 354
345 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 355 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
346 356
347 if ( which == Led_Mail ) { 357 if ( which == Led_Mail ) {
348 if ( fd >= 0 ) { 358 if ( fd >= 0 ) {
349 struct sharp_led_status leds; 359 struct sharp_led_status leds;
350 ::memset ( &leds, 0, sizeof( leds )); 360 ::memset ( &leds, 0, sizeof( leds ));
351 leds. which = SHARP_LED_MAIL_EXISTS; 361 leds. which = SHARP_LED_MAIL_EXISTS;
352 bool ok = true; 362 bool ok = true;
353 363
354 switch ( st ) { 364 switch ( st ) {
355 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 365 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
356 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 366 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
357 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 367 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
358 default : ok = false; 368 default : ok = false;
359 } 369 }
360 370
361 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 371 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
362 m_leds [0] = st; 372 m_leds [0] = st;
363 return true; 373 return true;
364 } 374 }
365 } 375 }
366 } 376 }
367 return false; 377 return false;
@@ -394,197 +404,209 @@ bool Zaurus::setSoftSuspend ( bool soft )
394 perror ( "APM_IOCGEVTSRC" ); 404 perror ( "APM_IOCGEVTSRC" );
395 } 405 }
396 else 406 else
397 perror ( "APM_IOCGEVTSRC" ); 407 perror ( "APM_IOCGEVTSRC" );
398 408
399 ::close ( fd ); 409 ::close ( fd );
400 } 410 }
401 else 411 else
402 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 412 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
403 413
404 return res; 414 return res;
405} 415}
406 416
407bool Zaurus::setDisplayBrightness( int bright ) 417bool Zaurus::setDisplayBrightness( int bright )
408{ 418{
409 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 419 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
410 bool res = false; 420 bool res = false;
411 421
412 if ( bright > 255 ) bright = 255; 422 if ( bright > 255 ) bright = 255;
413 if ( bright < 0 ) bright = 0; 423 if ( bright < 0 ) bright = 0;
414 424
415 if ( m_embedix ) 425 if ( m_embedix )
416 { 426 {
417 int numberOfSteps = displayBrightnessResolution(); 427 int numberOfSteps = displayBrightnessResolution();
418 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 428 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
419 if ( fd ) 429 if ( fd )
420 { 430 {
421 int val = ( bright * numberOfSteps ) / 255; 431 int val = ( bright * numberOfSteps ) / 255;
422 res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 432 res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
423 ::close ( fd ); 433 ::close ( fd );
424 } 434 }
425 } 435 }
426 else 436 else
427 { 437 {
428 qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); 438 qDebug( "Zaurus::setDisplayBrightness: ODevice handling for non-embedix kernels not yet implemented" );
429 } 439 }
430 return res; 440 return res;
431} 441}
432 442
433bool Zaurus::setDisplayStatus( bool on ) 443bool Zaurus::setDisplayStatus( bool on )
434{ 444{
435 bool res = false; 445 bool res = false;
436 if ( m_embedix ) 446 if ( m_embedix )
437 { 447 {
438 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 448 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
439 if ( fd ) 449 if ( fd )
440 { 450 {
441 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 451 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
442 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 452 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
443 ::close ( fd ); 453 ::close ( fd );
444 } 454 }
445 } 455 }
446 else 456 else
447 { 457 {
448 qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); 458 qDebug( "Zaurus::setDisplayStatus: ODevice handling for non-embedix kernels not yet implemented" );
449 } 459 }
450 return res; 460 return res;
451} 461}
452 462
453bool Zaurus::suspend() 463bool Zaurus::suspend()
454{ 464{
455 qDebug("ODevice::suspend"); 465 qDebug("ODevice::suspend");
456 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 466 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
457 return false; 467 return false;
458 468
459 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 469 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
460 return false; 470 return false;
461 471
462 bool res = false; 472 bool res = false;
463 ODevice::sendSuspendmsg(); 473 ODevice::sendSuspendmsg();
464 474
465 struct timeval tvs, tvn; 475 struct timeval tvs, tvn;
466 ::gettimeofday ( &tvs, 0 ); 476 ::gettimeofday ( &tvs, 0 );
467 477
468 ::sync(); // flush fs caches 478 ::sync(); // flush fs caches
469 res = ( ::system ( "apm --suspend" ) == 0 ); 479 res = ( ::system ( "apm --suspend" ) == 0 );
470 480
471 // This is needed because the apm implementation is asynchronous and we 481 // This is needed because the apm implementation is asynchronous and we
472 // can not be sure when exactly the device is really suspended 482 // can not be sure when exactly the device is really suspended
473 if ( res ) { 483 if ( res ) {
474 do { // Yes, wait 15 seconds. This APM sucks big time. 484 do { // Yes, wait 15 seconds. This APM sucks big time.
475 ::usleep ( 200 * 1000 ); 485 ::usleep ( 200 * 1000 );
476 ::gettimeofday ( &tvn, 0 ); 486 ::gettimeofday ( &tvn, 0 );
477 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 487 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
478 } 488 }
479 489
480 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 490 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
481 return res; 491 return res;
482} 492}
483 493
484 494
485Transformation Zaurus::rotation() const 495Transformation Zaurus::rotation() const
486{ 496{
487 Transformation rot; 497 Transformation rot;
488 int handle = 0; 498 int handle = 0;
489 int retval = 0; 499 int retval = 0;
490 500
491 switch ( d->m_model ) { 501 switch ( d->m_model ) {
502 case Model_Zaurus_SLC3000: // fallthrough
492 case Model_Zaurus_SLC7x0: 503 case Model_Zaurus_SLC7x0:
493 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 504 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
494 if (handle == -1) { 505 if (handle == -1) {
495 return Rot270; 506 return Rot270;
496 } else { 507 } else {
497 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 508 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
498 ::close (handle); 509 ::close (handle);
499 510
500 if (retval == 2 ) 511 if (retval == 2 )
501 rot = Rot0; 512 rot = Rot0;
502 else 513 else
503 rot = Rot270; 514 rot = Rot270;
504 } 515 }
505 break; 516 break;
506 case Model_Zaurus_SLA300: 517 case Model_Zaurus_SL6000:
507 case Model_Zaurus_SLB600: 518 case Model_Zaurus_SLB600:
519 case Model_Zaurus_SLA300:
508 case Model_Zaurus_SL5500: 520 case Model_Zaurus_SL5500:
509 case Model_Zaurus_SL5000: 521 case Model_Zaurus_SL5000:
510 default: 522 default:
511 rot = d->m_rotation; 523 rot = d->m_rotation;
512 break; 524 break;
513 } 525 }
514 526
515 return rot; 527 return rot;
516} 528}
517ODirection Zaurus::direction() const 529ODirection Zaurus::direction() const
518{ 530{
519 ODirection dir; 531 ODirection dir;
520 int handle = 0; 532 int handle = 0;
521 int retval = 0; 533 int retval = 0;
522 switch ( d->m_model ) { 534 switch ( d->m_model ) {
535 case Model_Zaurus_SLC3000: // fallthrough
523 case Model_Zaurus_SLC7x0: 536 case Model_Zaurus_SLC7x0:
524 handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); 537 handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK );
525 if (handle == -1) { 538 if (handle == -1) {
526 dir = CW; 539 dir = CW;
527 } else { 540 } else {
528 retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); 541 retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION );
529 ::close (handle); 542 ::close (handle);
530 if (retval == 2 ) 543 if (retval == 2 )
531 dir = CCW; 544 dir = CCW;
532 else 545 else
533 dir = CW; 546 dir = CW;
534 } 547 }
535 break; 548 break;
549 case Model_Zaurus_SL6000:
536 case Model_Zaurus_SLA300: 550 case Model_Zaurus_SLA300:
537 case Model_Zaurus_SLB600: 551 case Model_Zaurus_SLB600:
538 case Model_Zaurus_SL5500: 552 case Model_Zaurus_SL5500:
539 case Model_Zaurus_SL5000: 553 case Model_Zaurus_SL5000:
540 default: dir = d->m_direction; 554 default: dir = d->m_direction;
541 break; 555 break;
542 } 556 }
543 return dir; 557 return dir;
544 558
545} 559}
546 560
547int Zaurus::displayBrightnessResolution() const 561int Zaurus::displayBrightnessResolution() const
548{ 562{
549 if (m_embedix) 563 if (m_embedix)
550 { 564 {
551 int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 565 int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
552 if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 ); 566 if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 );
553 else return 1; 567 else return 1;
554 } 568 }
555 else 569 else
556 { 570 {
557 qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); 571 qDebug( "Zaurus::displayBrightnessResolution: ODevice handling for non-embedix kernels not yet implemented" );
558 return 1; 572 return 1;
559 } 573 }
560} 574}
561 575
562bool Zaurus::hasHingeSensor() const 576bool Zaurus::hasHingeSensor() const
563{ 577{
564 return d->m_model == Model_Zaurus_SLC7x0; 578 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
565} 579}
566 580
567OHingeStatus Zaurus::readHingeSensor() 581OHingeStatus Zaurus::readHingeSensor()
568{ 582{
569 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 583 if (m_embedix)
570 if (handle == -1)
571 {
572 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
573 return CASE_UNKNOWN;
574 }
575 else
576 { 584 {
577 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 585 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
578 ::close (handle); 586 if (handle == -1)
579 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
580 { 587 {
581 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 588 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
582 return static_cast<OHingeStatus>( retval ); 589 return CASE_UNKNOWN;
583 } 590 }
584 else 591 else
585 { 592 {
586 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 593 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
587 return CASE_UNKNOWN; 594 ::close (handle);
595 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
596 {
597 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
598 return static_cast<OHingeStatus>( retval );
599 }
600 else
601 {
602 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
603 return CASE_UNKNOWN;
604 }
588 } 605 }
589 } 606 }
607 else
608 {
609 qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" );
610 return CASE_UNKNOWN;
611 }
590} 612}
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index 37ab876..ed9cf67 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -65,73 +65,74 @@
65#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 65#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
66 66
67#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 67#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
68#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 68#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
69#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 69#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
70 70
71// Rotation and Power Management 71// Rotation and Power Management
72#define SHARP_IOCTL_GET_ROTATION 0x413c 72#define SHARP_IOCTL_GET_ROTATION 0x413c
73 73
74#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 74#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
75#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 75#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
76#define APM_EVT_POWER_BUTTON (1 << 0) 76#define APM_EVT_POWER_BUTTON (1 << 0)
77 77
78// Brightness 78// Brightness
79#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" 79#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl"
80#define SHARP_FL_IOCTL_ON 1 80#define SHARP_FL_IOCTL_ON 1
81#define SHARP_FL_IOCTL_OFF 2 81#define SHARP_FL_IOCTL_OFF 2
82#define SHARP_FL_IOCTL_STEP_CONTRAST 100 82#define SHARP_FL_IOCTL_STEP_CONTRAST 100
83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
84#define SHARP_FL_IOCTL_GET_STEP 102 84#define SHARP_FL_IOCTL_GET_STEP 102
85 85
86namespace Opie { 86namespace Opie {
87namespace Core { 87namespace Core {
88namespace Internal { 88namespace Internal {
89
89class Zaurus : public ODevice 90class Zaurus : public ODevice
90{ 91{
91 protected: 92 protected:
92 virtual void init(const QString&); 93 virtual void init(const QString&);
93 virtual void initButtons(); 94 virtual void initButtons();
94 95
95 public: 96 public:
96 virtual bool setSoftSuspend( bool soft ); 97 virtual bool setSoftSuspend( bool soft );
97 98
98 virtual bool setDisplayBrightness( int b ); 99 virtual bool setDisplayBrightness( int b );
99 virtual bool setDisplayStatus( bool on ); 100 virtual bool setDisplayStatus( bool on );
100 virtual int displayBrightnessResolution() const; 101 virtual int displayBrightnessResolution() const;
101 102
102 virtual void playAlarmSound(); 103 virtual void playAlarmSound();
103 virtual void playKeySound(); 104 virtual void playKeySound();
104 virtual void playTouchSound(); 105 virtual void playTouchSound();
105 106
106 virtual QValueList <OLed> ledList() const; 107 virtual QValueList <OLed> ledList() const;
107 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 108 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
108 virtual OLedState ledState( OLed led ) const; 109 virtual OLedState ledState( OLed led ) const;
109 virtual bool setLedState( OLed led, OLedState st ); 110 virtual bool setLedState( OLed led, OLedState st );
110 111
111 virtual bool hasHingeSensor() const; 112 virtual bool hasHingeSensor() const;
112 virtual OHingeStatus readHingeSensor(); 113 virtual OHingeStatus readHingeSensor();
113 114
114 virtual bool suspend(); 115 virtual bool suspend();
115 virtual Transformation rotation() const; 116 virtual Transformation rotation() const;
116 virtual ODirection direction() const; 117 virtual ODirection direction() const;
117 118
118 protected: 119 protected:
119 virtual void buzzer ( int snd ); 120 virtual void buzzer( int snd );
120 121
121 OLedState m_leds [1]; 122 OLedState m_leds[1];
122 bool m_embedix; 123 bool m_embedix;
123}; 124};
124 125
125struct z_button { 126struct z_button {
126 Qt::Key code; 127 Qt::Key code;
127 char *utext; 128 char *utext;
128 char *pix; 129 char *pix;
129 char *fpressedservice; 130 char *fpressedservice;
130 char *fpressedaction; 131 char *fpressedaction;
131 char *fheldservice; 132 char *fheldservice;
132 char *fheldaction; 133 char *fheldaction;
133}; 134};
134} 135}
135} 136}
136} 137}
137#endif 138#endif