summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp111
1 files changed, 63 insertions, 48 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 62dc9d4..17ae389 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -219,965 +219,966 @@ struct i_button {
219 "QPE/Launcher", "home()", 219 "QPE/Launcher", "home()",
220 "buttonsettings", "raise()" }, 220 "buttonsettings", "raise()" },
221 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 221 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
222 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 222 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
223 "devicebuttons/ipaq_record", 223 "devicebuttons/ipaq_record",
224 "QPE/VMemo", "toggleRecord()", 224 "QPE/VMemo", "toggleRecord()",
225 "sound", "raise()" }, 225 "sound", "raise()" },
226}; 226};
227 227
228struct z_button { 228struct z_button {
229 Qt::Key code; 229 Qt::Key code;
230 char *utext; 230 char *utext;
231 char *pix; 231 char *pix;
232 char *fpressedservice; 232 char *fpressedservice;
233 char *fpressedaction; 233 char *fpressedaction;
234 char *fheldservice; 234 char *fheldservice;
235 char *fheldaction; 235 char *fheldaction;
236} z_buttons [] = { 236} z_buttons [] = {
237 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 237 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
238 "devicebuttons/z_calendar", 238 "devicebuttons/z_calendar",
239 "datebook", "nextView()", 239 "datebook", "nextView()",
240 "today", "raise()" }, 240 "today", "raise()" },
241 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 241 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
242 "devicebuttons/z_contact", 242 "devicebuttons/z_contact",
243 "addressbook", "raise()", 243 "addressbook", "raise()",
244 "addressbook", "beamBusinessCard()" }, 244 "addressbook", "beamBusinessCard()" },
245 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 245 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
246 "devicebuttons/z_home", 246 "devicebuttons/z_home",
247 "QPE/Launcher", "home()", 247 "QPE/Launcher", "home()",
248 "buttonsettings", "raise()" }, 248 "buttonsettings", "raise()" },
249 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 249 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
250 "devicebuttons/z_menu", 250 "devicebuttons/z_menu",
251 "QPE/TaskBar", "toggleMenu()", 251 "QPE/TaskBar", "toggleMenu()",
252 "QPE/TaskBar", "toggleStartMenu()" }, 252 "QPE/TaskBar", "toggleStartMenu()" },
253 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 253 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
254 "devicebuttons/z_mail", 254 "devicebuttons/z_mail",
255 "mail", "raise()", 255 "mail", "raise()",
256 "mail", "newMail()" }, 256 "mail", "newMail()" },
257}; 257};
258 258
259struct z_button z_buttons_c700 [] = { 259struct z_button z_buttons_c700 [] = {
260 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 260 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
261 "devicebuttons/z_calendar", 261 "devicebuttons/z_calendar",
262 "datebook", "nextView()", 262 "datebook", "nextView()",
263 "today", "raise()" }, 263 "today", "raise()" },
264 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 264 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
265 "devicebuttons/z_contact", 265 "devicebuttons/z_contact",
266 "addressbook", "raise()", 266 "addressbook", "raise()",
267 "addressbook", "beamBusinessCard()" }, 267 "addressbook", "beamBusinessCard()" },
268 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 268 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
269 "devicebuttons/z_home", 269 "devicebuttons/z_home",
270 "QPE/Launcher", "home()", 270 "QPE/Launcher", "home()",
271 "buttonsettings", "raise()" }, 271 "buttonsettings", "raise()" },
272 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 272 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
273 "devicebuttons/z_menu", 273 "devicebuttons/z_menu",
274 "QPE/TaskBar", "toggleMenu()", 274 "QPE/TaskBar", "toggleMenu()",
275 "QPE/TaskBar", "toggleStartMenu()" }, 275 "QPE/TaskBar", "toggleStartMenu()" },
276 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 276 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
277 "", 277 "",
278 "QPE/Rotation", "flip()", 278 "QPE/Rotation", "flip()",
279 "QPE/Rotation", "flip()" }, 279 "QPE/Rotation", "flip()" },
280}; 280};
281 281
282struct s_button { 282struct s_button {
283 uint model; 283 uint model;
284 Qt::Key code; 284 Qt::Key code;
285 char *utext; 285 char *utext;
286 char *pix; 286 char *pix;
287 char *fpressedservice; 287 char *fpressedservice;
288 char *fpressedaction; 288 char *fpressedaction;
289 char *fheldservice; 289 char *fheldservice;
290 char *fheldaction; 290 char *fheldaction;
291} simpad_buttons [] = { 291} simpad_buttons [] = {
292 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 292 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
293 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 293 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
294 "devicebuttons/simpad_lower_up", 294 "devicebuttons/simpad_lower_up",
295 "datebook", "nextView()", 295 "datebook", "nextView()",
296 "today", "raise()" }, 296 "today", "raise()" },
297 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 297 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
298 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 298 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
299 "devicebuttons/simpad_lower_down", 299 "devicebuttons/simpad_lower_down",
300 "addressbook", "raise()", 300 "addressbook", "raise()",
301 "addressbook", "beamBusinessCard()" }, 301 "addressbook", "beamBusinessCard()" },
302 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 302 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
303 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 303 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
304 "devicebuttons/simpad_lower_right", 304 "devicebuttons/simpad_lower_right",
305 "QPE/TaskBar", "toggleMenu()", 305 "QPE/TaskBar", "toggleMenu()",
306 "QPE/TaskBar", "toggleStartMenu()" }, 306 "QPE/TaskBar", "toggleStartMenu()" },
307 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 307 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
308 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 308 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
309 "devicebuttons/simpad_lower_left", 309 "devicebuttons/simpad_lower_left",
310 "mail", "raise()", 310 "mail", "raise()",
311 "mail", "newMail()" }, 311 "mail", "newMail()" },
312 312
313 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 313 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
314 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 314 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
315 "devicebuttons/simpad_upper_up", 315 "devicebuttons/simpad_upper_up",
316 "QPE/Launcher", "home()", 316 "QPE/Launcher", "home()",
317 "buttonsettings", "raise()" }, 317 "buttonsettings", "raise()" },
318 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 318 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
319 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 319 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
320 "devicebuttons/simpad_upper_down", 320 "devicebuttons/simpad_upper_down",
321 "addressbook", "raise()", 321 "addressbook", "raise()",
322 "addressbook", "beamBusinessCard()" }, 322 "addressbook", "beamBusinessCard()" },
323 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 323 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
324 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 324 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
325 "devicebuttons/simpad_upper_right", 325 "devicebuttons/simpad_upper_right",
326 "QPE/TaskBar", "toggleMenu()", 326 "QPE/TaskBar", "toggleMenu()",
327 "QPE/TaskBar", "toggleStartMenu()" }, 327 "QPE/TaskBar", "toggleStartMenu()" },
328 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 328 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
329 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 329 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
330 "devicebuttons/simpad_upper_left", 330 "devicebuttons/simpad_upper_left",
331 "QPE/Rotation", "flip()", 331 "QPE/Rotation", "flip()",
332 "QPE/Rotation", "flip()" }, 332 "QPE/Rotation", "flip()" },
333 /* 333 /*
334 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 334 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
335 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 335 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
336 "devicebuttons/simpad_lower_upper", 336 "devicebuttons/simpad_lower_upper",
337 "QPE/Launcher", "home()", 337 "QPE/Launcher", "home()",
338 "buttonsettings", "raise()" }, 338 "buttonsettings", "raise()" },
339 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 339 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
340 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 340 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
341 "devicebuttons/simpad_upper_lower", 341 "devicebuttons/simpad_upper_lower",
342 "QPE/Launcher", "home()", 342 "QPE/Launcher", "home()",
343 "buttonsettings", "raise()" }, 343 "buttonsettings", "raise()" },
344 */ 344 */
345}; 345};
346 346
347struct r_button { 347struct r_button {
348 uint model; 348 uint model;
349 Qt::Key code; 349 Qt::Key code;
350 char *utext; 350 char *utext;
351 char *pix; 351 char *pix;
352 char *fpressedservice; 352 char *fpressedservice;
353 char *fpressedaction; 353 char *fpressedaction;
354 char *fheldservice; 354 char *fheldservice;
355 char *fheldaction; 355 char *fheldaction;
356} ramses_buttons [] = { 356} ramses_buttons [] = {
357 { Model_Ramses_MNCI, 357 { Model_Ramses_MNCI,
358 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 358 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
359 "devicebuttons/z_menu", 359 "devicebuttons/z_menu",
360 "QPE/TaskBar", "toggleMenu()", 360 "QPE/TaskBar", "toggleMenu()",
361 "QPE/TaskBar", "toggleStartMenu()" }, 361 "QPE/TaskBar", "toggleStartMenu()" },
362 { Model_Ramses_MNCI, 362 { Model_Ramses_MNCI,
363 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 363 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
364 "devicebuttons/ipaq_home", 364 "devicebuttons/ipaq_home",
365 "QPE/Launcher", "home()", 365 "QPE/Launcher", "home()",
366 "buttonsettings", "raise()" }, 366 "buttonsettings", "raise()" },
367}; 367};
368 368
369static QCString makeChannel ( const char *str ) 369static QCString makeChannel ( const char *str )
370{ 370{
371 if ( str && !::strchr ( str, '/' )) 371 if ( str && !::strchr ( str, '/' ))
372 return QCString ( "QPE/Application/" ) + str; 372 return QCString ( "QPE/Application/" ) + str;
373 else 373 else
374 return str; 374 return str;
375} 375}
376 376
377static inline bool isQWS() 377static inline bool isQWS()
378{ 378{
379 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 379 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
380} 380}
381 381
382ODevice *ODevice::inst ( ) 382ODevice *ODevice::inst ( )
383{ 383{
384 static ODevice *dev = 0; 384 static ODevice *dev = 0;
385 385
386 if ( !dev ) { 386 if ( !dev ) {
387 if ( QFile::exists ( "/proc/hal/model" )) 387 if ( QFile::exists ( "/proc/hal/model" ))
388 dev = new iPAQ ( ); 388 dev = new iPAQ ( );
389 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 389 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
390 dev = new Zaurus ( ); 390 dev = new Zaurus ( );
391 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 391 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
392 dev = new SIMpad ( ); 392 dev = new SIMpad ( );
393 else if ( QFile::exists ( "/proc/sys/board/name" )) 393 else if ( QFile::exists ( "/proc/sys/board/name" ))
394 dev = new Ramses ( ); 394 dev = new Ramses ( );
395 else 395 else
396 dev = new ODevice ( ); 396 dev = new ODevice ( );
397 397
398 dev-> init ( ); 398 dev-> init ( );
399 } 399 }
400 return dev; 400 return dev;
401} 401}
402 402
403 403
404/************************************************** 404/**************************************************
405 * 405 *
406 * common 406 * common
407 * 407 *
408 **************************************************/ 408 **************************************************/
409 409
410 410
411ODevice::ODevice ( ) 411ODevice::ODevice ( )
412{ 412{
413 d = new ODeviceData; 413 d = new ODeviceData;
414 414
415 d-> m_modelstr = "Unknown"; 415 d-> m_modelstr = "Unknown";
416 d-> m_model = Model_Unknown; 416 d-> m_model = Model_Unknown;
417 d-> m_vendorstr = "Unknown"; 417 d-> m_vendorstr = "Unknown";
418 d-> m_vendor = Vendor_Unknown; 418 d-> m_vendor = Vendor_Unknown;
419 d-> m_systemstr = "Unknown"; 419 d-> m_systemstr = "Unknown";
420 d-> m_system = System_Unknown; 420 d-> m_system = System_Unknown;
421 d-> m_sysverstr = "0.0"; 421 d-> m_sysverstr = "0.0";
422 d-> m_rotation = Rot0; 422 d-> m_rotation = Rot0;
423 d-> m_direction = CW; 423 d-> m_direction = CW;
424 424
425 d-> m_holdtime = 1000; // 1000ms 425 d-> m_holdtime = 1000; // 1000ms
426 d-> m_buttons = 0; 426 d-> m_buttons = 0;
427 d-> m_cpu_frequencies = new QStrList; 427 d-> m_cpu_frequencies = new QStrList;
428} 428}
429 429
430void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 430void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
431{ 431{
432 if ( msg == "deviceButtonMappingChanged()" ) { 432 if ( msg == "deviceButtonMappingChanged()" ) {
433 reloadButtonMapping ( ); 433 reloadButtonMapping ( );
434 } 434 }
435} 435}
436 436
437void ODevice::init ( ) 437void ODevice::init ( )
438{ 438{
439} 439}
440 440
441/** 441/**
442 * This method initialises the button mapping 442 * This method initialises the button mapping
443 */ 443 */
444void ODevice::initButtons ( ) 444void ODevice::initButtons ( )
445{ 445{
446 if ( d-> m_buttons ) 446 if ( d-> m_buttons )
447 return; 447 return;
448 448
449 // Simulation uses iPAQ 3660 device buttons 449 // Simulation uses iPAQ 3660 device buttons
450 450
451 qDebug ( "init Buttons" ); 451 qDebug ( "init Buttons" );
452 d-> m_buttons = new QValueList <ODeviceButton>; 452 d-> m_buttons = new QValueList <ODeviceButton>;
453 453
454 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 454 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
455 i_button *ib = ipaq_buttons + i; 455 i_button *ib = ipaq_buttons + i;
456 ODeviceButton b; 456 ODeviceButton b;
457 457
458 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 458 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
459 b. setKeycode ( ib-> code ); 459 b. setKeycode ( ib-> code );
460 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 460 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
461 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 461 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
462 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 462 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
463 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 463 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
464 d-> m_buttons-> append ( b ); 464 d-> m_buttons-> append ( b );
465 } 465 }
466 } 466 }
467 reloadButtonMapping ( ); 467 reloadButtonMapping ( );
468 468
469 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 469 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
470 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 470 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
471} 471}
472 472
473ODevice::~ODevice ( ) 473ODevice::~ODevice ( )
474{ 474{
475// we leak m_devicebuttons and m_cpu_frequency
476// but it's a singleton and it is not so importantant
477// -zecke
475 delete d; 478 delete d;
476} 479}
477 480
478bool ODevice::setSoftSuspend ( bool /*soft*/ ) 481bool ODevice::setSoftSuspend ( bool /*soft*/ )
479{ 482{
480 return false; 483 return false;
481} 484}
482 485
483//#include <linux/apm_bios.h> 486//#include <linux/apm_bios.h>
484 487
485#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 488#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
486 489
487/** 490/**
488 * This method will try to suspend the device 491 * This method will try to suspend the device
489 * It only works if the user is the QWS Server and the apm application 492 * It only works if the user is the QWS Server and the apm application
490 * is installed. 493 * is installed.
491 * It tries to suspend and then waits some time cause some distributions 494 * It tries to suspend and then waits some time cause some distributions
492 * do have asynchronus apm implementations. 495 * do have asynchronus apm implementations.
493 * This method will either fail and return false or it'll suspend the 496 * This method will either fail and return false or it'll suspend the
494 * device and return once the device got woken up 497 * device and return once the device got woken up
495 * 498 *
496 * @return if the device got suspended 499 * @return if the device got suspended
497 */ 500 */
498bool ODevice::suspend ( ) 501bool ODevice::suspend ( )
499{ 502{
500 qDebug("ODevice::suspend"); 503 qDebug("ODevice::suspend");
501 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 504 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
502 return false; 505 return false;
503 506
504 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 507 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
505 return false; 508 return false;
506 509
507 bool res = false; 510 bool res = false;
508 511
509 struct timeval tvs, tvn; 512 struct timeval tvs, tvn;
510 ::gettimeofday ( &tvs, 0 ); 513 ::gettimeofday ( &tvs, 0 );
511 514
512 ::sync ( ); // flush fs caches 515 ::sync ( ); // flush fs caches
513 res = ( ::system ( "apm --suspend" ) == 0 ); 516 res = ( ::system ( "apm --suspend" ) == 0 );
514 517
515 // This is needed because the iPAQ apm implementation is asynchronous and we 518 // This is needed because the iPAQ apm implementation is asynchronous and we
516 // can not be sure when exactly the device is really suspended 519 // can not be sure when exactly the device is really suspended
517 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 520 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
518 521
519 if ( res ) { 522 if ( res ) {
520 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 523 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
521 ::usleep ( 200 * 1000 ); 524 ::usleep ( 200 * 1000 );
522 ::gettimeofday ( &tvn, 0 ); 525 ::gettimeofday ( &tvn, 0 );
523 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 526 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
524 } 527 }
525 528
526 return res; 529 return res;
527} 530}
528 531
529//#include <linux/fb.h> better not rely on kernel headers in userspace ... 532//#include <linux/fb.h> better not rely on kernel headers in userspace ...
530 533
531#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 534#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
532 535
533/* VESA Blanking Levels */ 536/* VESA Blanking Levels */
534#define VESA_NO_BLANKING 0 537#define VESA_NO_BLANKING 0
535#define VESA_VSYNC_SUSPEND 1 538#define VESA_VSYNC_SUSPEND 1
536#define VESA_HSYNC_SUSPEND 2 539#define VESA_HSYNC_SUSPEND 2
537#define VESA_POWERDOWN 3 540#define VESA_POWERDOWN 3
538 541
539/** 542/**
540 * This sets the display on or off 543 * This sets the display on or off
541 */ 544 */
542bool ODevice::setDisplayStatus ( bool on ) 545bool ODevice::setDisplayStatus ( bool on )
543{ 546{
544 qDebug("ODevice::setDisplayStatus(%d)", on); 547 qDebug("ODevice::setDisplayStatus(%d)", on);
545 548
546 if ( d-> m_model == Model_Unknown ) 549 if ( d-> m_model == Model_Unknown )
547 return false; 550 return false;
548 551
549 bool res = false; 552 bool res = false;
550 int fd; 553 int fd;
551 554
552 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 555 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
553 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 556 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
554 ::close ( fd ); 557 ::close ( fd );
555 } 558 }
556 return res; 559 return res;
557} 560}
558 561
559/** 562/**
560 * This sets the display brightness 563 * This sets the display brightness
561 * 564 *
562 * @param p The brightness to be set on a scale from 0 to 255 565 * @param p The brightness to be set on a scale from 0 to 255
563 * @return success or failure 566 * @return success or failure
564 */ 567 */
565bool ODevice::setDisplayBrightness ( int p) 568bool ODevice::setDisplayBrightness ( int p)
566{ 569{
567 Q_UNUSED( p ) 570 Q_UNUSED( p )
568 return false; 571 return false;
569} 572}
570 573
571/** 574/**
572 * @return returns the number of steppings on the brightness slider 575 * @return returns the number of steppings on the brightness slider
573 * in the Light-'n-Power settings. 576 * in the Light-'n-Power settings.
574 */ 577 */
575int ODevice::displayBrightnessResolution ( ) const 578int ODevice::displayBrightnessResolution ( ) const
576{ 579{
577 return 16; 580 return 16;
578} 581}
579 582
580/** 583/**
581 * This sets the display contrast 584 * This sets the display contrast
582 * @param p The contrast to be set on a scale from 0 to 255 585 * @param p The contrast to be set on a scale from 0 to 255
583 * @return success or failure 586 * @return success or failure
584 */ 587 */
585bool ODevice::setDisplayContrast ( int p) 588bool ODevice::setDisplayContrast ( int p)
586{ 589{
587 Q_UNUSED( p ) 590 Q_UNUSED( p )
588 return false; 591 return false;
589} 592}
590 593
591/** 594/**
592 * @return return the max value for the brightness settings slider 595 * @return return the max value for the brightness settings slider
593 * or 0 if the device doesn't support setting of a contrast 596 * or 0 if the device doesn't support setting of a contrast
594 */ 597 */
595int ODevice::displayContrastResolution ( ) const 598int ODevice::displayContrastResolution ( ) const
596{ 599{
597 return 0; 600 return 0;
598} 601}
599 602
600/** 603/**
601 * This returns the vendor as string 604 * This returns the vendor as string
602 * @return Vendor as QString 605 * @return Vendor as QString
603 */ 606 */
604QString ODevice::vendorString ( ) const 607QString ODevice::vendorString ( ) const
605{ 608{
606 return d-> m_vendorstr; 609 return d-> m_vendorstr;
607} 610}
608 611
609/** 612/**
610 * This returns the vendor as one of the values of OVendor 613 * This returns the vendor as one of the values of OVendor
611 * @return OVendor 614 * @return OVendor
612 */ 615 */
613OVendor ODevice::vendor ( ) const 616OVendor ODevice::vendor ( ) const
614{ 617{
615 return d-> m_vendor; 618 return d-> m_vendor;
616} 619}
617 620
618/** 621/**
619 * This returns the model as a string 622 * This returns the model as a string
620 * @return A string representing the model 623 * @return A string representing the model
621 */ 624 */
622QString ODevice::modelString ( ) const 625QString ODevice::modelString ( ) const
623{ 626{
624 return d-> m_modelstr; 627 return d-> m_modelstr;
625} 628}
626 629
627/** 630/**
628 * This does return the OModel used 631 * This does return the OModel used
629 */ 632 */
630OModel ODevice::model ( ) const 633OModel ODevice::model ( ) const
631{ 634{
632 return d-> m_model; 635 return d-> m_model;
633} 636}
634 637
635/** 638/**
636 * This does return the systen name 639 * This does return the systen name
637 */ 640 */
638QString ODevice::systemString ( ) const 641QString ODevice::systemString ( ) const
639{ 642{
640 return d-> m_systemstr; 643 return d-> m_systemstr;
641} 644}
642 645
643/** 646/**
644 * Return System as OSystem value 647 * Return System as OSystem value
645 */ 648 */
646OSystem ODevice::system ( ) const 649OSystem ODevice::system ( ) const
647{ 650{
648 return d-> m_system; 651 return d-> m_system;
649} 652}
650 653
651/** 654/**
652 * @return the version string of the base system 655 * @return the version string of the base system
653 */ 656 */
654QString ODevice::systemVersionString ( ) const 657QString ODevice::systemVersionString ( ) const
655{ 658{
656 return d-> m_sysverstr; 659 return d-> m_sysverstr;
657} 660}
658 661
659/** 662/**
660 * @return the current Transformation 663 * @return the current Transformation
661 */ 664 */
662Transformation ODevice::rotation ( ) const 665Transformation ODevice::rotation ( ) const
663{ 666{
664 return d-> m_rotation; 667 return d-> m_rotation;
665} 668}
666 669
667/** 670/**
668 * @return the current rotation direction 671 * @return the current rotation direction
669 */ 672 */
670ODirection ODevice::direction ( ) const 673ODirection ODevice::direction ( ) const
671{ 674{
672 return d-> m_direction; 675 return d-> m_direction;
673} 676}
674 677
675/** 678/**
676 * This plays an alarmSound 679 * This plays an alarmSound
677 */ 680 */
678void ODevice::alarmSound ( ) 681void ODevice::alarmSound ( )
679{ 682{
680#ifndef QT_NO_SOUND 683#ifndef QT_NO_SOUND
681 static Sound snd ( "alarm" ); 684 static Sound snd ( "alarm" );
682 685
683 if ( snd. isFinished ( )) 686 if ( snd. isFinished ( ))
684 snd. play ( ); 687 snd. play ( );
685#endif 688#endif
686} 689}
687 690
688/** 691/**
689 * This plays a key sound 692 * This plays a key sound
690 */ 693 */
691void ODevice::keySound ( ) 694void ODevice::keySound ( )
692{ 695{
693#ifndef QT_NO_SOUND 696#ifndef QT_NO_SOUND
694 static Sound snd ( "keysound" ); 697 static Sound snd ( "keysound" );
695 698
696 if ( snd. isFinished ( )) 699 if ( snd. isFinished ( ))
697 snd. play ( ); 700 snd. play ( );
698#endif 701#endif
699} 702}
700 703
701/** 704/**
702 * This plays a touch sound 705 * This plays a touch sound
703 */ 706 */
704void ODevice::touchSound ( ) 707void ODevice::touchSound ( )
705{ 708{
706#ifndef QT_NO_SOUND 709#ifndef QT_NO_SOUND
707 static Sound snd ( "touchsound" ); 710 static Sound snd ( "touchsound" );
708 711
709 if ( snd. isFinished ( )) 712 if ( snd. isFinished ( ))
710 snd. play ( ); 713 snd. play ( );
711#endif 714#endif
712} 715}
713 716
714/** 717/**
715 * This method will return a list of leds 718 * This method will return a list of leds
716 * available on this device 719 * available on this device
717 * @return a list of LEDs. 720 * @return a list of LEDs.
718 */ 721 */
719QValueList <OLed> ODevice::ledList ( ) const 722QValueList <OLed> ODevice::ledList ( ) const
720{ 723{
721 return QValueList <OLed> ( ); 724 return QValueList <OLed> ( );
722} 725}
723 726
724/** 727/**
725 * This does return the state of the LEDs 728 * This does return the state of the LEDs
726 */ 729 */
727QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 730QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
728{ 731{
729 return QValueList <OLedState> ( ); 732 return QValueList <OLedState> ( );
730} 733}
731 734
732/** 735/**
733 * @return the state for a given OLed 736 * @return the state for a given OLed
734 */ 737 */
735OLedState ODevice::ledState ( OLed /*which*/ ) const 738OLedState ODevice::ledState ( OLed /*which*/ ) const
736{ 739{
737 return Led_Off; 740 return Led_Off;
738} 741}
739 742
740/** 743/**
741 * Set the state for a LED 744 * Set the state for a LED
742 * @param which Which OLed to use 745 * @param which Which OLed to use
743 * @param st The state to set 746 * @param st The state to set
744 * @return success or failure 747 * @return success or failure
745 */ 748 */
746bool ODevice::setLedState ( OLed which, OLedState st ) 749bool ODevice::setLedState ( OLed which, OLedState st )
747{ 750{
748 Q_UNUSED( which ) 751 Q_UNUSED( which )
749 Q_UNUSED( st ) 752 Q_UNUSED( st )
750 return false; 753 return false;
751} 754}
752 755
753/** 756/**
754 * @return if the device has a light sensor 757 * @return if the device has a light sensor
755 */ 758 */
756bool ODevice::hasLightSensor ( ) const 759bool ODevice::hasLightSensor ( ) const
757{ 760{
758 return false; 761 return false;
759} 762}
760 763
761/** 764/**
762 * @return a value from the light senso 765 * @return a value from the light senso
763 */ 766 */
764int ODevice::readLightSensor ( ) 767int ODevice::readLightSensor ( )
765{ 768{
766 return -1; 769 return -1;
767} 770}
768 771
769/** 772/**
770 * @return the light sensor resolution whatever that is ;) 773 * @return the light sensor resolution whatever that is ;)
771 */ 774 */
772int ODevice::lightSensorResolution ( ) const 775int ODevice::lightSensorResolution ( ) const
773{ 776{
774 return 0; 777 return 0;
775} 778}
776 779
777/** 780/**
778 * @return a list with CPU frequencies supported by the hardware 781 * @return a list with CPU frequencies supported by the hardware
779 */ 782 */
780const QStrList &ODevice::allowedCpuFrequencies ( ) const 783const QStrList &ODevice::allowedCpuFrequencies ( ) const
781{ 784{
782 return *d->m_cpu_frequencies; 785 return *d->m_cpu_frequencies;
783} 786}
784 787
785 788
786/** 789/**
787 * Set desired CPU frequency 790 * Set desired CPU frequency
788 * 791 *
789 * @param index index into d->m_cpu_frequencies of the frequency to be set 792 * @param index index into d->m_cpu_frequencies of the frequency to be set
790 */ 793 */
791bool ODevice::setCurrentCpuFrequency(uint index) 794bool ODevice::setCurrentCpuFrequency(uint index)
792{ 795{
793 if (index >= d->m_cpu_frequencies->count()) 796 if (index >= d->m_cpu_frequencies->count())
794 return false; 797 return false;
795 798
796 char *freq = d->m_cpu_frequencies->at(index); 799 char *freq = d->m_cpu_frequencies->at(index);
797 qWarning("set freq to %s", freq); 800 qWarning("set freq to %s", freq);
798 801
799 int fd; 802 int fd;
800 803
801 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 804 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
802 char writeCommand[50]; 805 char writeCommand[50];
803 const int count = sprintf(writeCommand, "%s\n", freq); 806 const int count = sprintf(writeCommand, "%s\n", freq);
804 int res = (::write(fd, writeCommand, count) != -1); 807 int res = (::write(fd, writeCommand, count) != -1);
805 ::close(fd); 808 ::close(fd);
806 return res; 809 return res;
807 } 810 }
808 811
809 return false; 812 return false;
810} 813}
811 814
812 815
813/** 816/**
814 * @return a list of hardware buttons 817 * @return a list of hardware buttons
815 */ 818 */
816const QValueList <ODeviceButton> &ODevice::buttons ( ) 819const QValueList <ODeviceButton> &ODevice::buttons ( )
817{ 820{
818 initButtons ( ); 821 initButtons ( );
819 822
820 return *d-> m_buttons; 823 return *d-> m_buttons;
821} 824}
822 825
823/** 826/**
824 * @return The amount of time that would count as a hold 827 * @return The amount of time that would count as a hold
825 */ 828 */
826uint ODevice::buttonHoldTime ( ) const 829uint ODevice::buttonHoldTime ( ) const
827{ 830{
828 return d-> m_holdtime; 831 return d-> m_holdtime;
829} 832}
830 833
831/** 834/**
832 * This method return a ODeviceButton for a key code 835 * This method return a ODeviceButton for a key code
833 * or 0 if no special hardware button is available for the device 836 * or 0 if no special hardware button is available for the device
834 * 837 *
835 * @return The devicebutton or 0l 838 * @return The devicebutton or 0l
836 * @see ODeviceButton 839 * @see ODeviceButton
837 */ 840 */
838const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 841const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
839{ 842{
840 initButtons ( ); 843 initButtons ( );
841 844
842 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 845 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
843 if ( (*it). keycode ( ) == code ) 846 if ( (*it). keycode ( ) == code )
844 return &(*it); 847 return &(*it);
845 } 848 }
846 return 0; 849 return 0;
847} 850}
848 851
849void ODevice::reloadButtonMapping ( ) 852void ODevice::reloadButtonMapping ( )
850{ 853{
851 initButtons ( ); 854 initButtons ( );
852 855
853 Config cfg ( "ButtonSettings" ); 856 Config cfg ( "ButtonSettings" );
854 857
855 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 858 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
856 ODeviceButton &b = ( *d-> m_buttons ) [i]; 859 ODeviceButton &b = ( *d-> m_buttons ) [i];
857 QString group = "Button" + QString::number ( i ); 860 QString group = "Button" + QString::number ( i );
858 861
859 QCString pch, hch; 862 QCString pch, hch;
860 QCString pm, hm; 863 QCString pm, hm;
861 QByteArray pdata, hdata; 864 QByteArray pdata, hdata;
862 865
863 if ( cfg. hasGroup ( group )) { 866 if ( cfg. hasGroup ( group )) {
864 cfg. setGroup ( group ); 867 cfg. setGroup ( group );
865 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 868 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
866 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 869 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
867 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 870 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
868 871
869 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 872 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
870 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 873 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
871 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 874 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
872 } 875 }
873 876
874 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 877 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
875 878
876 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 879 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
877 } 880 }
878} 881}
879 882
880void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 883void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
881{ 884{
882 initButtons ( ); 885 initButtons ( );
883 886
884 QString mb_chan; 887 QString mb_chan;
885 888
886 if ( button >= (int) d-> m_buttons-> count ( )) 889 if ( button >= (int) d-> m_buttons-> count ( ))
887 return; 890 return;
888 891
889 ODeviceButton &b = ( *d-> m_buttons ) [button]; 892 ODeviceButton &b = ( *d-> m_buttons ) [button];
890 b. setPressedAction ( action ); 893 b. setPressedAction ( action );
891 894
892 mb_chan=b. pressedAction ( ). channel ( ); 895 mb_chan=b. pressedAction ( ). channel ( );
893 896
894 Config buttonFile ( "ButtonSettings" ); 897 Config buttonFile ( "ButtonSettings" );
895 buttonFile. setGroup ( "Button" + QString::number ( button )); 898 buttonFile. setGroup ( "Button" + QString::number ( button ));
896 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 899 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
897 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 900 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
898 901
899 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 902 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
900 903
901 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 904 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
902} 905}
903 906
904void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 907void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
905{ 908{
906 initButtons ( ); 909 initButtons ( );
907 910
908 if ( button >= (int) d-> m_buttons-> count ( )) 911 if ( button >= (int) d-> m_buttons-> count ( ))
909 return; 912 return;
910 913
911 ODeviceButton &b = ( *d-> m_buttons ) [button]; 914 ODeviceButton &b = ( *d-> m_buttons ) [button];
912 b. setHeldAction ( action ); 915 b. setHeldAction ( action );
913 916
914 Config buttonFile ( "ButtonSettings" ); 917 Config buttonFile ( "ButtonSettings" );
915 buttonFile. setGroup ( "Button" + QString::number ( button )); 918 buttonFile. setGroup ( "Button" + QString::number ( button ));
916 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 919 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
917 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 920 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
918 921
919 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 922 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
920 923
921 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 924 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
922} 925}
923void ODevice::virtual_hook( int id, void* data ) { 926void ODevice::virtual_hook(int, void* ){
924 Q_UNUSED(id);
925 Q_UNUSED(data);
926}
927 927
928}
928 929
929 930
930/************************************************** 931/**************************************************
931 * 932 *
932 * iPAQ 933 * iPAQ
933 * 934 *
934 **************************************************/ 935 **************************************************/
935 936
936void iPAQ::init ( ) 937void iPAQ::init ( )
937{ 938{
938 d-> m_vendorstr = "HP"; 939 d-> m_vendorstr = "HP";
939 d-> m_vendor = Vendor_HP; 940 d-> m_vendor = Vendor_HP;
940 941
941 QFile f ( "/proc/hal/model" ); 942 QFile f ( "/proc/hal/model" );
942 943
943 if ( f. open ( IO_ReadOnly )) { 944 if ( f. open ( IO_ReadOnly )) {
944 QTextStream ts ( &f ); 945 QTextStream ts ( &f );
945 946
946 d-> m_modelstr = "H" + ts. readLine ( ); 947 d-> m_modelstr = "H" + ts. readLine ( );
947 948
948 if ( d-> m_modelstr == "H3100" ) 949 if ( d-> m_modelstr == "H3100" )
949 d-> m_model = Model_iPAQ_H31xx; 950 d-> m_model = Model_iPAQ_H31xx;
950 else if ( d-> m_modelstr == "H3600" ) 951 else if ( d-> m_modelstr == "H3600" )
951 d-> m_model = Model_iPAQ_H36xx; 952 d-> m_model = Model_iPAQ_H36xx;
952 else if ( d-> m_modelstr == "H3700" ) 953 else if ( d-> m_modelstr == "H3700" )
953 d-> m_model = Model_iPAQ_H37xx; 954 d-> m_model = Model_iPAQ_H37xx;
954 else if ( d-> m_modelstr == "H3800" ) 955 else if ( d-> m_modelstr == "H3800" )
955 d-> m_model = Model_iPAQ_H38xx; 956 d-> m_model = Model_iPAQ_H38xx;
956 else if ( d-> m_modelstr == "H3900" ) 957 else if ( d-> m_modelstr == "H3900" )
957 d-> m_model = Model_iPAQ_H39xx; 958 d-> m_model = Model_iPAQ_H39xx;
958 else 959 else
959 d-> m_model = Model_Unknown; 960 d-> m_model = Model_Unknown;
960 961
961 f. close ( ); 962 f. close ( );
962 } 963 }
963 964
964 switch ( d-> m_model ) { 965 switch ( d-> m_model ) {
965 case Model_iPAQ_H31xx: 966 case Model_iPAQ_H31xx:
966 case Model_iPAQ_H38xx: 967 case Model_iPAQ_H38xx:
967 d-> m_rotation = Rot90; 968 d-> m_rotation = Rot90;
968 break; 969 break;
969 case Model_iPAQ_H36xx: 970 case Model_iPAQ_H36xx:
970 case Model_iPAQ_H37xx: 971 case Model_iPAQ_H37xx:
971 case Model_iPAQ_H39xx: 972 case Model_iPAQ_H39xx:
972 default: 973 default:
973 d-> m_rotation = Rot270; 974 d-> m_rotation = Rot270;
974 break; 975 break;
975 } 976 }
976 977
977 f. setName ( "/etc/familiar-version" ); 978 f. setName ( "/etc/familiar-version" );
978 if ( f. open ( IO_ReadOnly )) { 979 if ( f. open ( IO_ReadOnly )) {
979 d-> m_systemstr = "Familiar"; 980 d-> m_systemstr = "Familiar";
980 d-> m_system = System_Familiar; 981 d-> m_system = System_Familiar;
981 982
982 QTextStream ts ( &f ); 983 QTextStream ts ( &f );
983 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 984 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
984 985
985 f. close ( ); 986 f. close ( );
986 } else { 987 } else {
987 f. setName ( "/etc/oz_version" ); 988 f. setName ( "/etc/oz_version" );
988 989
989 if ( f. open ( IO_ReadOnly )) { 990 if ( f. open ( IO_ReadOnly )) {
990 d-> m_systemstr = "OpenEmbedded/iPaq"; 991 d-> m_systemstr = "OpenEmbedded/iPaq";
991 d-> m_system = System_Familiar; 992 d-> m_system = System_Familiar;
992 993
993 QTextStream ts ( &f ); 994 QTextStream ts ( &f );
994 ts.setDevice ( &f ); 995 ts.setDevice ( &f );
995 d-> m_sysverstr = ts. readLine ( ); 996 d-> m_sysverstr = ts. readLine ( );
996 f. close ( ); 997 f. close ( );
997 } 998 }
998 } 999 }
999 1000
1000 1001
1001 1002
1002 1003
1003 1004
1004 m_leds [0] = m_leds [1] = Led_Off; 1005 m_leds [0] = m_leds [1] = Led_Off;
1005 1006
1006 m_power_timer = 0; 1007 m_power_timer = 0;
1007 1008
1008} 1009}
1009 1010
1010void iPAQ::initButtons ( ) 1011void iPAQ::initButtons ( )
1011{ 1012{
1012 if ( d-> m_buttons ) 1013 if ( d-> m_buttons )
1013 return; 1014 return;
1014 1015
1015 if ( isQWS( ) ) 1016 if ( isQWS( ) )
1016 QWSServer::setKeyboardFilter ( this ); 1017 QWSServer::setKeyboardFilter ( this );
1017 1018
1018 d-> m_buttons = new QValueList <ODeviceButton>; 1019 d-> m_buttons = new QValueList <ODeviceButton>;
1019 1020
1020 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1021 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1021 i_button *ib = ipaq_buttons + i; 1022 i_button *ib = ipaq_buttons + i;
1022 ODeviceButton b; 1023 ODeviceButton b;
1023 1024
1024 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1025 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1025 b. setKeycode ( ib-> code ); 1026 b. setKeycode ( ib-> code );
1026 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1027 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1027 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1028 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1028 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1029 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1029 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1030 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1030 1031
1031 d-> m_buttons-> append ( b ); 1032 d-> m_buttons-> append ( b );
1032 } 1033 }
1033 } 1034 }
1034 reloadButtonMapping ( ); 1035 reloadButtonMapping ( );
1035 1036
1036 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1037 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1037 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1038 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1038} 1039}
1039 1040
1040 1041
1041//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1042//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1042 1043
1043typedef struct { 1044typedef struct {
1044 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1045 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1045 unsigned char TotalTime; /* Units of 5 seconds */ 1046 unsigned char TotalTime; /* Units of 5 seconds */
1046 unsigned char OnTime; /* units of 100m/s */ 1047 unsigned char OnTime; /* units of 100m/s */
1047 unsigned char OffTime; /* units of 100m/s */ 1048 unsigned char OffTime; /* units of 100m/s */
1048} LED_IN; 1049} LED_IN;
1049 1050
1050typedef struct { 1051typedef struct {
1051 unsigned char mode; 1052 unsigned char mode;
1052 unsigned char pwr; 1053 unsigned char pwr;
1053 unsigned char brightness; 1054 unsigned char brightness;
1054} FLITE_IN; 1055} FLITE_IN;
1055 1056
1056#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1057#define LED_ON OD_IOW( 'f', 5, LED_IN )
1057#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1058#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1058 1059
1059 1060
1060QValueList <OLed> iPAQ::ledList ( ) const 1061QValueList <OLed> iPAQ::ledList ( ) const
1061{ 1062{
1062 QValueList <OLed> vl; 1063 QValueList <OLed> vl;
1063 vl << Led_Power; 1064 vl << Led_Power;
1064 1065
1065 if ( d-> m_model == Model_iPAQ_H38xx ) 1066 if ( d-> m_model == Model_iPAQ_H38xx )
1066 vl << Led_BlueTooth; 1067 vl << Led_BlueTooth;
1067 return vl; 1068 return vl;
1068} 1069}
1069 1070
1070QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1071QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1071{ 1072{
1072 QValueList <OLedState> vl; 1073 QValueList <OLedState> vl;
1073 1074
1074 if ( l == Led_Power ) 1075 if ( l == Led_Power )
1075 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1076 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1076 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1077 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1077 vl << Led_Off; // << Led_On << ??? 1078 vl << Led_Off; // << Led_On << ???
1078 1079
1079 return vl; 1080 return vl;
1080} 1081}
1081 1082
1082OLedState iPAQ::ledState ( OLed l ) const 1083OLedState iPAQ::ledState ( OLed l ) const
1083{ 1084{
1084 switch ( l ) { 1085 switch ( l ) {
1085 case Led_Power: 1086 case Led_Power:
1086 return m_leds [0]; 1087 return m_leds [0];
1087 case Led_BlueTooth: 1088 case Led_BlueTooth:
1088 return m_leds [1]; 1089 return m_leds [1];
1089 default: 1090 default:
1090 return Led_Off; 1091 return Led_Off;
1091 } 1092 }
1092} 1093}
1093 1094
1094bool iPAQ::setLedState ( OLed l, OLedState st ) 1095bool iPAQ::setLedState ( OLed l, OLedState st )
1095{ 1096{
1096 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1097 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1097 1098
1098 if ( l == Led_Power ) { 1099 if ( l == Led_Power ) {
1099 if ( fd >= 0 ) { 1100 if ( fd >= 0 ) {
1100 LED_IN leds; 1101 LED_IN leds;
1101 ::memset ( &leds, 0, sizeof( leds )); 1102 ::memset ( &leds, 0, sizeof( leds ));
1102 leds. TotalTime = 0; 1103 leds. TotalTime = 0;
1103 leds. OnTime = 0; 1104 leds. OnTime = 0;
1104 leds. OffTime = 1; 1105 leds. OffTime = 1;
1105 leds. OffOnBlink = 2; 1106 leds. OffOnBlink = 2;
1106 1107
1107 switch ( st ) { 1108 switch ( st ) {
1108 case Led_Off : leds. OffOnBlink = 0; break; 1109 case Led_Off : leds. OffOnBlink = 0; break;
1109 case Led_On : leds. OffOnBlink = 1; break; 1110 case Led_On : leds. OffOnBlink = 1; break;
1110 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1111 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1111 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1112 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1112 } 1113 }
1113 1114
1114 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1115 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1115 m_leds [0] = st; 1116 m_leds [0] = st;
1116 return true; 1117 return true;
1117 } 1118 }
1118 } 1119 }
1119 } 1120 }
1120 return false; 1121 return false;
1121} 1122}
1122 1123
1123 1124
1124bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1125bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1125{ 1126{
1126 int newkeycode = keycode; 1127 int newkeycode = keycode;
1127 1128
1128 switch ( keycode ) { 1129 switch ( keycode ) {
1129 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1130 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1130 case HardKey_Menu: { 1131 case HardKey_Menu: {
1131 if (( d-> m_model == Model_iPAQ_H38xx ) || 1132 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1132 ( d-> m_model == Model_iPAQ_H39xx )) { 1133 ( d-> m_model == Model_iPAQ_H39xx )) {
1133 newkeycode = HardKey_Mail; 1134 newkeycode = HardKey_Mail;
1134 } 1135 }
1135 break; 1136 break;
1136 } 1137 }
1137 1138
1138 // Rotate cursor keys 180° 1139 // Rotate cursor keys 180°
1139 case Key_Left : 1140 case Key_Left :
1140 case Key_Right: 1141 case Key_Right:
1141 case Key_Up : 1142 case Key_Up :
1142 case Key_Down : { 1143 case Key_Down : {
1143 if (( d-> m_model == Model_iPAQ_H31xx ) || 1144 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1144 ( d-> m_model == Model_iPAQ_H38xx )) { 1145 ( d-> m_model == Model_iPAQ_H38xx )) {
1145 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1146 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1146 } 1147 }
1147 break; 1148 break;
1148 } 1149 }
1149 1150
1150 // map Power Button short/long press to F34/F35 1151 // map Power Button short/long press to F34/F35
1151 case Key_SysReq: { 1152 case Key_SysReq: {
1152 if ( isPress ) { 1153 if ( isPress ) {
1153 if ( m_power_timer ) 1154 if ( m_power_timer )
1154 killTimer ( m_power_timer ); 1155 killTimer ( m_power_timer );
1155 m_power_timer = startTimer ( 500 ); 1156 m_power_timer = startTimer ( 500 );
1156 } 1157 }
1157 else if ( m_power_timer ) { 1158 else if ( m_power_timer ) {
1158 killTimer ( m_power_timer ); 1159 killTimer ( m_power_timer );
1159 m_power_timer = 0; 1160 m_power_timer = 0;
1160 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1161 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1161 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1162 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1162 } 1163 }
1163 newkeycode = Key_unknown; 1164 newkeycode = Key_unknown;
1164 break; 1165 break;
1165 } 1166 }
1166 } 1167 }
1167 1168
1168 if ( newkeycode != keycode ) { 1169 if ( newkeycode != keycode ) {
1169 if ( newkeycode != Key_unknown ) 1170 if ( newkeycode != Key_unknown )
1170 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1171 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1171 return true; 1172 return true;
1172 } 1173 }
1173 else 1174 else
1174 return false; 1175 return false;
1175} 1176}
1176 1177
1177void iPAQ::timerEvent ( QTimerEvent * ) 1178void iPAQ::timerEvent ( QTimerEvent * )
1178{ 1179{
1179 killTimer ( m_power_timer ); 1180 killTimer ( m_power_timer );
1180 m_power_timer = 0; 1181 m_power_timer = 0;
1181 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1182 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1182 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1183 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1183} 1184}
@@ -1395,749 +1396,763 @@ void Zaurus::init ( )
1395 d-> m_direction = CCW; 1396 d-> m_direction = CCW;
1396 } 1397 }
1397 break; 1398 break;
1398 case Model_Zaurus_SLB600: 1399 case Model_Zaurus_SLB600:
1399 case Model_Zaurus_SL5500: 1400 case Model_Zaurus_SL5500:
1400 case Model_Zaurus_SL5000: 1401 case Model_Zaurus_SL5000:
1401 default: 1402 default:
1402 d-> m_rotation = Rot270; 1403 d-> m_rotation = Rot270;
1403 break; 1404 break;
1404 } 1405 }
1405 m_leds [0] = Led_Off; 1406 m_leds [0] = Led_Off;
1406} 1407}
1407 1408
1408void Zaurus::initButtons ( ) 1409void Zaurus::initButtons ( )
1409{ 1410{
1410 if ( d-> m_buttons ) 1411 if ( d-> m_buttons )
1411 return; 1412 return;
1412 1413
1413 d-> m_buttons = new QValueList <ODeviceButton>; 1414 d-> m_buttons = new QValueList <ODeviceButton>;
1414 1415
1415 struct z_button * pz_buttons; 1416 struct z_button * pz_buttons;
1416 int buttoncount; 1417 int buttoncount;
1417 switch ( d-> m_model ) { 1418 switch ( d-> m_model ) {
1418 case Model_Zaurus_SLC700: 1419 case Model_Zaurus_SLC700:
1419 pz_buttons = z_buttons_c700; 1420 pz_buttons = z_buttons_c700;
1420 buttoncount = ARRAY_SIZE(z_buttons_c700); 1421 buttoncount = ARRAY_SIZE(z_buttons_c700);
1421 break; 1422 break;
1422 default: 1423 default:
1423 pz_buttons = z_buttons; 1424 pz_buttons = z_buttons;
1424 buttoncount = ARRAY_SIZE(z_buttons); 1425 buttoncount = ARRAY_SIZE(z_buttons);
1425 break; 1426 break;
1426 } 1427 }
1427 1428
1428 for ( int i = 0; i < buttoncount; i++ ) { 1429 for ( int i = 0; i < buttoncount; i++ ) {
1429 struct z_button *zb = pz_buttons + i; 1430 struct z_button *zb = pz_buttons + i;
1430 ODeviceButton b; 1431 ODeviceButton b;
1431 1432
1432 b. setKeycode ( zb-> code ); 1433 b. setKeycode ( zb-> code );
1433 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1434 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1434 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1435 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1435 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1436 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1436 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1437 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1437 1438
1438 d-> m_buttons-> append ( b ); 1439 d-> m_buttons-> append ( b );
1439 } 1440 }
1440 1441
1441 reloadButtonMapping ( ); 1442 reloadButtonMapping ( );
1442 1443
1443 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1444 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1444 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1445 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1445} 1446}
1446 1447
1447#include <unistd.h> 1448#include <unistd.h>
1448#include <fcntl.h> 1449#include <fcntl.h>
1449#include <sys/ioctl.h> 1450#include <sys/ioctl.h>
1450 1451
1451//#include <asm/sharp_char.h> // including kernel headers is evil ... 1452//#include <asm/sharp_char.h> // including kernel headers is evil ...
1452 1453
1453#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1454#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1454 1455
1455 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1456 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1456#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1457#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1457 1458
1458#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1459#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1459#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1460#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1460#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1461#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1461 1462
1462/* --- for SHARP_BUZZER device --- */ 1463/* --- for SHARP_BUZZER device --- */
1463 1464
1464 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1465 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1465//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1466//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1466 1467
1467#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1468#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1468#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1469#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1469#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1470#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1470#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1471#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1471#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1472#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1472 1473
1473//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1474//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1474//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1475//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1475 1476
1476//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1477//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1477//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1478//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1478//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1479//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1479//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1480//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1480//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1481//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1481//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1482//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1482//#define SHARP_PDA_APPSTART 9 /* application start */ 1483//#define SHARP_PDA_APPSTART 9 /* application start */
1483//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1484//#define SHARP_PDA_APPQUIT 10 /* application ends */
1484 1485
1485//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1486//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1486//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1487//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1487//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1488//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1488//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1489//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1489// 1490//
1490 1491
1491 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1492 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1492#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1493#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1493 1494
1494typedef struct sharp_led_status { 1495typedef struct sharp_led_status {
1495 int which; /* select which LED status is wanted. */ 1496 int which; /* select which LED status is wanted. */
1496 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1497 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1497} sharp_led_status; 1498} sharp_led_status;
1498 1499
1499#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1500#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1500 1501
1501#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1502#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1502#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1503#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1503#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1504#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1504 1505
1505// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1506// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1506 1507
1507#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1508#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1508#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1509#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1509#define APM_EVT_POWER_BUTTON (1 << 0) 1510#define APM_EVT_POWER_BUTTON (1 << 0)
1510 1511
1511#define FL_IOCTL_STEP_CONTRAST 100 1512#define FL_IOCTL_STEP_CONTRAST 100
1512 1513
1513 1514
1514void Zaurus::buzzer ( int sound ) 1515void Zaurus::buzzer ( int sound )
1515{ 1516{
1516 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1517 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1517 1518
1518 if ( fd >= 0 ) { 1519 if ( fd >= 0 ) {
1519 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1520 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1520 ::close ( fd ); 1521 ::close ( fd );
1521 } 1522 }
1522} 1523}
1523 1524
1524 1525
1525void Zaurus::alarmSound ( ) 1526void Zaurus::alarmSound ( )
1526{ 1527{
1527 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1528 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1528} 1529}
1529 1530
1530void Zaurus::touchSound ( ) 1531void Zaurus::touchSound ( )
1531{ 1532{
1532 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1533 buzzer ( SHARP_BUZ_TOUCHSOUND );
1533} 1534}
1534 1535
1535void Zaurus::keySound ( ) 1536void Zaurus::keySound ( )
1536{ 1537{
1537 buzzer ( SHARP_BUZ_KEYSOUND ); 1538 buzzer ( SHARP_BUZ_KEYSOUND );
1538} 1539}
1539 1540
1540 1541
1541QValueList <OLed> Zaurus::ledList ( ) const 1542QValueList <OLed> Zaurus::ledList ( ) const
1542{ 1543{
1543 QValueList <OLed> vl; 1544 QValueList <OLed> vl;
1544 vl << Led_Mail; 1545 vl << Led_Mail;
1545 return vl; 1546 return vl;
1546} 1547}
1547 1548
1548QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1549QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1549{ 1550{
1550 QValueList <OLedState> vl; 1551 QValueList <OLedState> vl;
1551 1552
1552 if ( l == Led_Mail ) 1553 if ( l == Led_Mail )
1553 vl << Led_Off << Led_On << Led_BlinkSlow; 1554 vl << Led_Off << Led_On << Led_BlinkSlow;
1554 return vl; 1555 return vl;
1555} 1556}
1556 1557
1557OLedState Zaurus::ledState ( OLed which ) const 1558OLedState Zaurus::ledState ( OLed which ) const
1558{ 1559{
1559 if ( which == Led_Mail ) 1560 if ( which == Led_Mail )
1560 return m_leds [0]; 1561 return m_leds [0];
1561 else 1562 else
1562 return Led_Off; 1563 return Led_Off;
1563} 1564}
1564 1565
1565bool Zaurus::setLedState ( OLed which, OLedState st ) 1566bool Zaurus::setLedState ( OLed which, OLedState st )
1566{ 1567{
1567 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1568 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1568 1569
1569 if ( which == Led_Mail ) { 1570 if ( which == Led_Mail ) {
1570 if ( fd >= 0 ) { 1571 if ( fd >= 0 ) {
1571 struct sharp_led_status leds; 1572 struct sharp_led_status leds;
1572 ::memset ( &leds, 0, sizeof( leds )); 1573 ::memset ( &leds, 0, sizeof( leds ));
1573 leds. which = SHARP_LED_MAIL_EXISTS; 1574 leds. which = SHARP_LED_MAIL_EXISTS;
1574 bool ok = true; 1575 bool ok = true;
1575 1576
1576 switch ( st ) { 1577 switch ( st ) {
1577 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1578 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1578 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1579 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1579 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1580 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1580 default : ok = false; 1581 default : ok = false;
1581 } 1582 }
1582 1583
1583 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1584 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1584 m_leds [0] = st; 1585 m_leds [0] = st;
1585 return true; 1586 return true;
1586 } 1587 }
1587 } 1588 }
1588 } 1589 }
1589 return false; 1590 return false;
1590} 1591}
1591 1592
1592bool Zaurus::setSoftSuspend ( bool soft ) 1593bool Zaurus::setSoftSuspend ( bool soft )
1593{ 1594{
1594 bool res = false; 1595 bool res = false;
1595 int fd; 1596 int fd;
1596 1597
1597 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1598 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1598 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1599 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1599 1600
1600 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1601 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1601 1602
1602 if ( sources >= 0 ) { 1603 if ( sources >= 0 ) {
1603 if ( soft ) 1604 if ( soft )
1604 sources &= ~APM_EVT_POWER_BUTTON; 1605 sources &= ~APM_EVT_POWER_BUTTON;
1605 else 1606 else
1606 sources |= APM_EVT_POWER_BUTTON; 1607 sources |= APM_EVT_POWER_BUTTON;
1607 1608
1608 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1609 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1609 res = true; 1610 res = true;
1610 else 1611 else
1611 perror ( "APM_IOCGEVTSRC" ); 1612 perror ( "APM_IOCGEVTSRC" );
1612 } 1613 }
1613 else 1614 else
1614 perror ( "APM_IOCGEVTSRC" ); 1615 perror ( "APM_IOCGEVTSRC" );
1615 1616
1616 ::close ( fd ); 1617 ::close ( fd );
1617 } 1618 }
1618 else 1619 else
1619 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1620 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1620 1621
1621 return res; 1622 return res;
1622} 1623}
1623 1624
1624 1625
1625bool Zaurus::setDisplayBrightness ( int bright ) 1626bool Zaurus::setDisplayBrightness ( int bright )
1626{ 1627{
1627 bool res = false; 1628 bool res = false;
1628 int fd; 1629 int fd;
1629 1630
1630 if ( bright > 255 ) 1631 if ( bright > 255 )
1631 bright = 255; 1632 bright = 255;
1632 if ( bright < 0 ) 1633 if ( bright < 0 )
1633 bright = 0; 1634 bright = 0;
1634 1635
1635 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1636 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1636 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1637 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1637 if ( bright && !bl ) 1638 if ( bright && !bl )
1638 bl = 1; 1639 bl = 1;
1639 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1640 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1640 ::close ( fd ); 1641 ::close ( fd );
1641 } 1642 }
1642 return res; 1643 return res;
1643} 1644}
1644 1645
1645 1646
1646int Zaurus::displayBrightnessResolution ( ) const 1647int Zaurus::displayBrightnessResolution ( ) const
1647{ 1648{
1648 return 5; 1649 return 5;
1649} 1650}
1650 1651
1651
1652/************************************************** 1652/**************************************************
1653 * 1653 *
1654 * SIMpad 1654 * SIMpad
1655 * 1655 *
1656 **************************************************/ 1656 **************************************************/
1657 1657
1658void SIMpad::init ( ) 1658void SIMpad::init ( )
1659{ 1659{
1660 d-> m_vendorstr = "SIEMENS"; 1660 d-> m_vendorstr = "SIEMENS";
1661 d-> m_vendor = Vendor_SIEMENS; 1661 d-> m_vendor = Vendor_SIEMENS;
1662 1662
1663 QFile f ( "/proc/hal/model" ); 1663 QFile f ( "/proc/hal/model" );
1664 1664
1665 //TODO Implement model checking 1665 //TODO Implement model checking
1666 //FIXME For now we assume an SL4 1666 //FIXME For now we assume an SL4
1667 1667
1668 d-> m_modelstr = "SL4"; 1668 d-> m_modelstr = "SL4";
1669 d-> m_model = Model_SIMpad_SL4; 1669 d-> m_model = Model_SIMpad_SL4;
1670 1670
1671 switch ( d-> m_model ) { 1671 switch ( d-> m_model ) {
1672 default: 1672 default:
1673 d-> m_rotation = Rot0; 1673 d-> m_rotation = Rot0;
1674 d-> m_direction = CCW; 1674 d-> m_direction = CCW;
1675 d-> m_holdtime = 1000; // 1000ms 1675 d-> m_holdtime = 1000; // 1000ms
1676 1676
1677 break; 1677 break;
1678 } 1678 }
1679 1679
1680 f. setName ( "/etc/familiar-version" ); 1680 f. setName ( "/etc/familiar-version" );
1681 if ( f. open ( IO_ReadOnly )) { 1681 if ( f. open ( IO_ReadOnly )) {
1682 d-> m_systemstr = "Familiar"; 1682 d-> m_systemstr = "Familiar";
1683 d-> m_system = System_Familiar; 1683 d-> m_system = System_Familiar;
1684 1684
1685 QTextStream ts ( &f ); 1685 QTextStream ts ( &f );
1686 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1686 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1687 1687
1688 f. close ( ); 1688 f. close ( );
1689 } else { 1689 } else {
1690 f. setName ( "/etc/oz_version" ); 1690 f. setName ( "/etc/oz_version" );
1691 1691
1692 if ( f. open ( IO_ReadOnly )) { 1692 if ( f. open ( IO_ReadOnly )) {
1693 d-> m_systemstr = "OpenEmbedded/SIMpad"; 1693 d-> m_systemstr = "OpenEmbedded/SIMpad";
1694 d-> m_system = System_OpenZaurus; 1694 d-> m_system = System_OpenZaurus;
1695 1695
1696 QTextStream ts ( &f ); 1696 QTextStream ts ( &f );
1697 ts.setDevice ( &f ); 1697 ts.setDevice ( &f );
1698 d-> m_sysverstr = ts. readLine ( ); 1698 d-> m_sysverstr = ts. readLine ( );
1699 f. close ( ); 1699 f. close ( );
1700 } 1700 }
1701 } 1701 }
1702 1702
1703 m_leds [0] = m_leds [1] = Led_Off; 1703 m_leds [0] = m_leds [1] = Led_Off;
1704 1704
1705 m_power_timer = 0; 1705 m_power_timer = 0;
1706 1706
1707} 1707}
1708 1708
1709void SIMpad::initButtons ( ) 1709void SIMpad::initButtons ( )
1710{ 1710{
1711 if ( d-> m_buttons ) 1711 if ( d-> m_buttons )
1712 return; 1712 return;
1713 1713
1714 if ( isQWS( ) ) 1714 if ( isQWS( ) )
1715 QWSServer::setKeyboardFilter ( this ); 1715 QWSServer::setKeyboardFilter ( this );
1716 1716
1717 d-> m_buttons = new QValueList <ODeviceButton>; 1717 d-> m_buttons = new QValueList <ODeviceButton>;
1718 1718
1719 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 1719 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
1720 s_button *sb = simpad_buttons + i; 1720 s_button *sb = simpad_buttons + i;
1721 ODeviceButton b; 1721 ODeviceButton b;
1722 1722
1723 if (( sb-> model & d-> m_model ) == d-> m_model ) { 1723 if (( sb-> model & d-> m_model ) == d-> m_model ) {
1724 b. setKeycode ( sb-> code ); 1724 b. setKeycode ( sb-> code );
1725 b. setUserText ( QObject::tr ( "Button", sb-> utext )); 1725 b. setUserText ( QObject::tr ( "Button", sb-> utext ));
1726 b. setPixmap ( Resource::loadPixmap ( sb-> pix )); 1726 b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
1727 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); 1727 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
1728 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); 1728 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
1729 1729
1730 d-> m_buttons-> append ( b ); 1730 d-> m_buttons-> append ( b );
1731 } 1731 }
1732 } 1732 }
1733 reloadButtonMapping ( ); 1733 reloadButtonMapping ( );
1734 1734
1735 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1735 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1736 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1736 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1737} 1737}
1738 1738
1739// SIMpad boardcontrol register CS3 1739// SIMpad boardcontrol register CS3
1740#define SIMPAD_BOARDCONTROL "/proc/cs3" 1740#define SIMPAD_BOARDCONTROL "/proc/cs3"
1741#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 1741#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
1742#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 1742#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
1743#define SIMPAD_EN1 0x0004 // This is only for EPROM's 1743#define SIMPAD_EN1 0x0004 // This is only for EPROM's
1744#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 1744#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
1745#define SIMPAD_DISPLAY_ON 0x0010 1745#define SIMPAD_DISPLAY_ON 0x0010
1746#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 1746#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
1747#define SIMPAD_MQ_RESET 0x0040 1747#define SIMPAD_MQ_RESET 0x0040
1748#define SIMPAD_PCMCIA_RESET 0x0080 1748#define SIMPAD_PCMCIA_RESET 0x0080
1749#define SIMPAD_DECT_POWER_ON 0x0100 1749#define SIMPAD_DECT_POWER_ON 0x0100
1750#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 1750#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
1751#define SIMPAD_RS232_ON 0x0400 1751#define SIMPAD_RS232_ON 0x0400
1752#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 1752#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
1753#define SIMPAD_LED2_ON 0x1000 1753#define SIMPAD_LED2_ON 0x1000
1754#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 1754#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
1755#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 1755#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
1756#define SIMPAD_RESET_SIMCARD 0x8000 1756#define SIMPAD_RESET_SIMCARD 0x8000
1757 1757
1758//SIMpad touchscreen backlight strength control 1758//SIMpad touchscreen backlight strength control
1759#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 1759#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
1760#define SIMPAD_BACKLIGHT_MASK 0x00a10044 1760#define SIMPAD_BACKLIGHT_MASK 0x00a10044
1761 1761
1762QValueList <OLed> SIMpad::ledList ( ) const 1762QValueList <OLed> SIMpad::ledList ( ) const
1763{ 1763{
1764 QValueList <OLed> vl; 1764 QValueList <OLed> vl;
1765 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 1765 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
1766 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 1766 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
1767 return vl; 1767 return vl;
1768} 1768}
1769 1769
1770QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 1770QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
1771{ 1771{
1772 QValueList <OLedState> vl; 1772 QValueList <OLedState> vl;
1773 1773
1774 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 1774 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
1775 vl << Led_Off << Led_On; 1775 vl << Led_Off << Led_On;
1776 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 1776 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
1777 //vl << Led_Off; 1777 //vl << Led_Off;
1778 return vl; 1778 return vl;
1779} 1779}
1780 1780
1781OLedState SIMpad::ledState ( OLed l ) const 1781OLedState SIMpad::ledState ( OLed l ) const
1782{ 1782{
1783 switch ( l ) { 1783 switch ( l ) {
1784 case Led_Power: 1784 case Led_Power:
1785 return m_leds [0]; 1785 return m_leds [0];
1786 //case Led_Mail: 1786 //case Led_Mail:
1787 //return m_leds [1]; 1787 //return m_leds [1];
1788 default: 1788 default:
1789 return Led_Off; 1789 return Led_Off;
1790 } 1790 }
1791} 1791}
1792 1792
1793bool SIMpad::setLedState ( OLed l, OLedState st ) 1793bool SIMpad::setLedState ( OLed l, OLedState st )
1794{ 1794{
1795 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 1795 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
1796 1796
1797 if ( l == Led_Power ) { 1797 if ( l == Led_Power ) {
1798 if ( fd >= 0 ) { 1798 if ( fd >= 0 ) {
1799 LED_IN leds; 1799 LED_IN leds;
1800 ::memset ( &leds, 0, sizeof( leds )); 1800 ::memset ( &leds, 0, sizeof( leds ));
1801 leds. TotalTime = 0; 1801 leds. TotalTime = 0;
1802 leds. OnTime = 0; 1802 leds. OnTime = 0;
1803 leds. OffTime = 1; 1803 leds. OffTime = 1;
1804 leds. OffOnBlink = 2; 1804 leds. OffOnBlink = 2;
1805 1805
1806 switch ( st ) { 1806 switch ( st ) {
1807 case Led_Off : leds. OffOnBlink = 0; break; 1807 case Led_Off : leds. OffOnBlink = 0; break;
1808 case Led_On : leds. OffOnBlink = 1; break; 1808 case Led_On : leds. OffOnBlink = 1; break;
1809 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1809 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1810 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1810 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1811 } 1811 }
1812 1812
1813 { 1813 {
1814 /*TODO Implement this like that: 1814 /*TODO Implement this like that:
1815 read from cs3 1815 read from cs3
1816 && with SIMPAD_LED2_ON 1816 && with SIMPAD_LED2_ON
1817 write to cs3 */ 1817 write to cs3 */
1818 m_leds [0] = st; 1818 m_leds [0] = st;
1819 return true; 1819 return true;
1820 } 1820 }
1821 } 1821 }
1822 } 1822 }
1823 return false; 1823 return false;
1824} 1824}
1825 1825
1826 1826
1827bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1827bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1828{ 1828{
1829 //TODO 1829 //TODO
1830 return false; 1830 return false;
1831} 1831}
1832 1832
1833void SIMpad::timerEvent ( QTimerEvent * ) 1833void SIMpad::timerEvent ( QTimerEvent * )
1834{ 1834{
1835 killTimer ( m_power_timer ); 1835 killTimer ( m_power_timer );
1836 m_power_timer = 0; 1836 m_power_timer = 0;
1837 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1837 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1838 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1838 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1839} 1839}
1840 1840
1841 1841
1842void SIMpad::alarmSound ( ) 1842void SIMpad::alarmSound ( )
1843{ 1843{
1844#ifndef QT_NO_SOUND 1844#ifndef QT_NO_SOUND
1845 static Sound snd ( "alarm" ); 1845 static Sound snd ( "alarm" );
1846 int fd; 1846 int fd;
1847 int vol; 1847 int vol;
1848 bool vol_reset = false; 1848 bool vol_reset = false;
1849 1849
1850 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1850 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1851 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1851 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1852 Config cfg ( "qpe" ); 1852 Config cfg ( "qpe" );
1853 cfg. setGroup ( "Volume" ); 1853 cfg. setGroup ( "Volume" );
1854 1854
1855 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1855 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1856 if ( volalarm < 0 ) 1856 if ( volalarm < 0 )
1857 volalarm = 0; 1857 volalarm = 0;
1858 else if ( volalarm > 100 ) 1858 else if ( volalarm > 100 )
1859 volalarm = 100; 1859 volalarm = 100;
1860 volalarm |= ( volalarm << 8 ); 1860 volalarm |= ( volalarm << 8 );
1861 1861
1862 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1862 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1863 vol_reset = true; 1863 vol_reset = true;
1864 } 1864 }
1865 } 1865 }
1866 1866
1867 snd. play ( ); 1867 snd. play ( );
1868 while ( !snd. isFinished ( )) 1868 while ( !snd. isFinished ( ))
1869 qApp-> processEvents ( ); 1869 qApp-> processEvents ( );
1870 1870
1871 if ( fd >= 0 ) { 1871 if ( fd >= 0 ) {
1872 if ( vol_reset ) 1872 if ( vol_reset )
1873 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1873 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1874 ::close ( fd ); 1874 ::close ( fd );
1875 } 1875 }
1876#endif 1876#endif
1877} 1877}
1878 1878
1879 1879
1880bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm 1880bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
1881{ 1881{
1882 qDebug( "ODevice for SIMpad: suspend()" ); 1882 qDebug( "ODevice for SIMpad: suspend()" );
1883 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 1883 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1884 return false; 1884 return false;
1885 1885
1886 bool res = false; 1886 bool res = false;
1887 1887
1888 struct timeval tvs, tvn; 1888 struct timeval tvs, tvn;
1889 ::gettimeofday ( &tvs, 0 ); 1889 ::gettimeofday ( &tvs, 0 );
1890 1890
1891 ::sync ( ); // flush fs caches 1891 ::sync ( ); // flush fs caches
1892 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) 1892 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
1893 1893
1894 return res; 1894 return res;
1895} 1895}
1896 1896
1897 1897
1898bool SIMpad::setSoftSuspend ( bool soft ) 1898bool SIMpad::setSoftSuspend ( bool soft )
1899{ 1899{
1900 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 1900 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
1901 return false; 1901 return false;
1902} 1902}
1903 1903
1904 1904
1905bool SIMpad::setDisplayStatus ( bool on ) 1905bool SIMpad::setDisplayStatus ( bool on )
1906{ 1906{
1907 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 1907 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
1908 1908
1909 bool res = false; 1909 bool res = false;
1910 int fd; 1910 int fd;
1911 1911
1912 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 1912 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
1913 1913
1914 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 1914 res = ( ::system( (const char*) cmdline ) == 0 );
1915 res = ( ::system( (const char*) cmdline ) == 0 ); 1915
1916 ::close ( fd );
1917 }
1918 return res; 1916 return res;
1919} 1917}
1920 1918
1921 1919
1922bool SIMpad::setDisplayBrightness ( int bright ) 1920bool SIMpad::setDisplayBrightness ( int bright )
1923{ 1921{
1924 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 1922 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
1925 bool res = false; 1923 bool res = false;
1926 int fd; 1924 int fd;
1927 1925
1928 if ( bright > 255 ) 1926 if ( bright > 255 )
1929 bright = 255; 1927 bright = 255;
1930 if ( bright < 0 ) 1928 if ( bright < 1 )
1931 bright = 0; 1929 bright = 0;
1932 1930
1933 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 1931 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
1934 int value = 255 - bright; 1932 int value = 255 - bright;
1935 const int mask = SIMPAD_BACKLIGHT_MASK; 1933 const int mask = SIMPAD_BACKLIGHT_MASK;
1936 value = value << 8; 1934 value = value << 8;
1937 value += mask; 1935 value += mask;
1938 char writeCommand[100]; 1936 char writeCommand[100];
1939 const int count = sprintf( writeCommand, "0x%x\n", value ); 1937 const int count = sprintf( writeCommand, "0x%x\n", value );
1940 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1938 res = ( ::write ( fd, writeCommand, count ) != -1 );
1941 ::close ( fd ); 1939 ::close ( fd );
1942 } 1940 }
1943 return res; 1941 return res;
1944} 1942}
1945 1943
1946 1944
1947int SIMpad::displayBrightnessResolution ( ) const 1945int SIMpad::displayBrightnessResolution ( ) const
1948{ 1946{
1949 switch ( model ( )) { 1947 return 255; // All SIMpad models share the same display
1950 case Model_SIMpad_CL4:
1951 case Model_SIMpad_SL4:
1952 case Model_SIMpad_SLC:
1953 case Model_SIMpad_TSinus:
1954 return 255; //TODO find out if this is save
1955
1956 default:
1957 return 2;
1958 }
1959} 1948}
1960 1949
1961/************************************************** 1950/**************************************************
1962 * 1951 *
1963 * Ramses 1952 * Ramses
1964 * 1953 *
1965 **************************************************/ 1954 **************************************************/
1966 1955
1967void Ramses::init() 1956void Ramses::init()
1968{ 1957{
1969 d->m_vendorstr = "M und N"; 1958 d->m_vendorstr = "M und N";
1970 d->m_vendor = Vendor_MundN; 1959 d->m_vendor = Vendor_MundN;
1971 1960
1972 QFile f("/proc/sys/board/ramses"); 1961 QFile f("/proc/sys/board/ramses");
1973 1962
1974 d->m_modelstr = "Ramses"; 1963 d->m_modelstr = "Ramses";
1975 d->m_model = Model_Ramses_MNCI; 1964 d->m_model = Model_Ramses_MNCI;
1976 1965
1977 d->m_rotation = Rot180; 1966 d->m_rotation = Rot0;
1978 d->m_direction = CW; 1967 d->m_holdtime = 1000;
1979 d->m_holdtime = 1000;
1980 1968
1981 f.setName("/etc/oz_version"); 1969 f.setName("/etc/oz_version");
1982 1970
1983 if (f.open(IO_ReadOnly)) { 1971 if (f.open(IO_ReadOnly)) {
1984 d->m_systemstr = "OpenEmbedded/Ramses"; 1972 d->m_systemstr = "OpenEmbedded/Ramses";
1985 d->m_system = System_OpenZaurus; 1973 d->m_system = System_OpenZaurus;
1986 1974
1987 QTextStream ts(&f); 1975 QTextStream ts(&f);
1988 ts.setDevice(&f); 1976 ts.setDevice(&f);
1989 d->m_sysverstr = ts.readLine(); 1977 d->m_sysverstr = ts.readLine();
1990 f.close(); 1978 f.close();
1991 } 1979 }
1992 1980
1993 m_power_timer = 0; 1981 m_power_timer = 0;
1994 1982
1995#ifdef QT_QWS_ALLOW_OVERCLOCK 1983#ifdef QT_QWS_ALLOW_OVERCLOCK
1996#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 1984#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
1997#define OC(x...) x 1985#define OC(x...) x
1998#else 1986#else
1999#define OC(x...) 1987#define OC(x...)
2000#endif 1988#endif
2001 1989
2002 1990
2003 // This table is true for a Intel XScale PXA 255 1991 // This table is true for a Intel XScale PXA 255
2004 1992
2005 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 1993 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
2006 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 1994 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
2007 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 1995 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
2008 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 1996 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
2009 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 1997 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
2010 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 1998 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
2011 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 1999 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
2012 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 2000 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
2013 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 2001 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
2014 2002
2015} 2003}
2016 2004
2017bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) 2005bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
2018{ 2006{
2019 Q_UNUSED( keycode ); 2007 Q_UNUSED( keycode );
2020 Q_UNUSED( modifiers ); 2008 Q_UNUSED( modifiers );
2021 Q_UNUSED( isPress ); 2009 Q_UNUSED( isPress );
2022 Q_UNUSED( autoRepeat ); 2010 Q_UNUSED( autoRepeat );
2023 return false; 2011 return false;
2024} 2012}
2025 2013
2026void Ramses::timerEvent(QTimerEvent *) 2014void Ramses::timerEvent(QTimerEvent *)
2027{ 2015{
2028 killTimer(m_power_timer); 2016 killTimer(m_power_timer);
2029 m_power_timer = 0; 2017 m_power_timer = 0;
2030 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); 2018 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
2031 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); 2019 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
2032} 2020}
2033 2021
2034 2022
2035bool Ramses::setSoftSuspend(bool soft) 2023bool Ramses::setSoftSuspend(bool soft)
2036{ 2024{
2037 Q_UNUSED(soft); 2025 qDebug("Ramses::setSoftSuspend(%d)", soft);
2038 return true; 2026#if 0
2039}
2040
2041bool Ramses::suspend()
2042{
2043 //qDebug("Ramses::suspend()");
2044 if ( !isQWS() ) // only qwsserver is allowed to suspend
2045 return false;
2046
2047 bool res = false; 2027 bool res = false;
2048 int fd; 2028 int fd;
2049 2029
2050 if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { 2030 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
2051 res = ( ::write ( fd, "1", 1 ) != -1 ); 2031 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
2032
2033 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
2034
2035 if (sources >= 0) {
2036 if (soft)
2037 sources &= ~APM_EVT_POWER_BUTTON;
2038 else
2039 sources |= APM_EVT_POWER_BUTTON;
2040
2041 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
2042 res = true;
2043 else
2044 perror("APM_IOCGEVTSRC");
2045 }
2046 else
2047 perror("APM_IOCGEVTSRC");
2048
2052 ::close(fd); 2049 ::close(fd);
2053 } 2050 }
2054 return res; 2051 else
2052 perror("/dev/apm_bios or /dev/misc/apm_bios");
2053
2054 return res;
2055#else
2056 return true;
2057#endif
2058}
2059
2060bool Ramses::suspend ( )
2061{
2062 qDebug("Ramses::suspend");
2063 return false;
2055} 2064}
2056 2065
2057/** 2066/**
2058 * This sets the display on or off 2067 * This sets the display on or off
2059 */ 2068 */
2060bool Ramses::setDisplayStatus(bool on) 2069bool Ramses::setDisplayStatus(bool on)
2061{ 2070{
2062 //qDebug("Ramses::setDisplayStatus(%d)", on); 2071 qDebug("Ramses::setDisplayStatus(%d)", on);
2072#if 0
2063 bool res = false; 2073 bool res = false;
2064 int fd; 2074 int fd;
2065 2075
2066 if ((fd = ::open ("/dev/fb/1", O_RDWR)) >= 0) { 2076 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
2067 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 2077 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
2068 ::close(fd); 2078 ::close(fd);
2069 } 2079 }
2070 return res; 2080 return res;
2081#else
2082 return true;
2083#endif
2071} 2084}
2072 2085
2073 2086
2074/* 2087/*
2075 * We get something between 0..255 into us 2088 * We get something between 0..255 into us
2076*/ 2089*/
2077bool Ramses::setDisplayBrightness(int bright) 2090bool Ramses::setDisplayBrightness(int bright)
2078{ 2091{
2079 //qDebug("Ramses::setDisplayBrightness(%d)", bright); 2092 qDebug("Ramses::setDisplayBrightness(%d)", bright);
2080 bool res = false; 2093 bool res = false;
2081 int fd; 2094 int fd;
2082 2095
2083 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 2096 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
2084 2097
2085 if (bright > 255 ) 2098 if (bright > 255 )
2086 bright = 255; 2099 bright = 255;
2087 if (bright < 0) 2100 if (bright < 0)
2088 bright = 0; 2101 bright = 0;
2089 2102
2090 // Turn backlight completely off 2103 // Turn backlight completely off
2091 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 2104 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
2092 char writeCommand[10]; 2105 char writeCommand[10];
2093 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 2106 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
2094 res = (::write(fd, writeCommand, count) != -1); 2107 res = (::write(fd, writeCommand, count) != -1);
2095 ::close(fd); 2108 ::close(fd);
2096 } 2109 }
2097 2110
2098 // scale backlight brightness to hardware 2111 // scale backlight brightness to hardware
2099 if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { 2112 bright = 500-(bright * 500 / 255);
2100 //qDebug(" %d -> pwm1", bright); 2113 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
2114 qDebug(" %d -> pwm1", bright);
2101 char writeCommand[100]; 2115 char writeCommand[100];
2102 const int count = sprintf(writeCommand, "%d\n", bright); 2116 const int count = sprintf(writeCommand, "%d\n", bright);
2103 res = (::write(fd, writeCommand, count) != -1); 2117 res = (::write(fd, writeCommand, count) != -1);
2104 ::close(fd); 2118 ::close(fd);
2105 } 2119 }
2106 return res; 2120 return res;
2107} 2121}
2108 2122
2109 2123
2110int Ramses::displayBrightnessResolution() const 2124int Ramses::displayBrightnessResolution() const
2111{ 2125{
2112 return 256; 2126 return 32;
2113} 2127}
2114 2128
2115bool Ramses::setDisplayContrast(int contr) 2129bool Ramses::setDisplayContrast(int contr)
2116{ 2130{
2117 //qDebug("Ramses::setDisplayContrast(%d)", contr); 2131 qDebug("Ramses::setDisplayContrast(%d)", contr);
2118 bool res = false; 2132 bool res = false;
2119 int fd; 2133 int fd;
2120 2134
2121 // pwm0 contrast: 20 steps 79..90 (dunkel->hell) 2135 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
2122 2136
2123 if (contr > 255 ) 2137 if (contr > 255 )
2124 contr = 255; 2138 contr = 255;
2125 if (contr < 0) 2139 if (contr < 0)
2126 contr = 0; 2140 contr = 0;
2141 contr = 90 - (contr * 20 / 255);
2127 2142
2128 if ((fd = ::open("/proc/sys/board/lcd_contrast", O_WRONLY)) >= 0) { 2143 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
2129 //qDebug(" %d -> pwm0", contr); 2144 qDebug(" %d -> pwm0", contr);
2130 char writeCommand[100]; 2145 char writeCommand[100];
2131 const int count = sprintf(writeCommand, "%d\n", contr); 2146 const int count = sprintf(writeCommand, "%d\n", contr);
2132 res = (::write(fd, writeCommand, count) != -1); 2147 res = (::write(fd, writeCommand, count) != -1);
2133 res = true; 2148 res = true;
2134 ::close(fd); 2149 ::close(fd);
2135 } 2150 }
2136 return res; 2151 return res;
2137} 2152}
2138 2153
2139 2154
2140int Ramses::displayContrastResolution() const 2155int Ramses::displayContrastResolution() const
2141{ 2156{
2142 return 256; 2157 return 20;
2143} 2158}