-rw-r--r-- | libopie/odevice.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 160568b..f808960 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -367,402 +367,406 @@ struct r_button { | |||
367 | 367 | ||
368 | static QCString makeChannel ( const char *str ) | 368 | static QCString makeChannel ( const char *str ) |
369 | { | 369 | { |
370 | if ( str && !::strchr ( str, '/' )) | 370 | if ( str && !::strchr ( str, '/' )) |
371 | return QCString ( "QPE/Application/" ) + str; | 371 | return QCString ( "QPE/Application/" ) + str; |
372 | else | 372 | else |
373 | return str; | 373 | return str; |
374 | } | 374 | } |
375 | 375 | ||
376 | static inline bool isQWS() | 376 | static inline bool isQWS() |
377 | { | 377 | { |
378 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 378 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
379 | } | 379 | } |
380 | 380 | ||
381 | ODevice *ODevice::inst ( ) | 381 | ODevice *ODevice::inst ( ) |
382 | { | 382 | { |
383 | static ODevice *dev = 0; | 383 | static ODevice *dev = 0; |
384 | 384 | ||
385 | if ( !dev ) { | 385 | if ( !dev ) { |
386 | if ( QFile::exists ( "/proc/hal/model" )) | 386 | if ( QFile::exists ( "/proc/hal/model" )) |
387 | dev = new iPAQ ( ); | 387 | dev = new iPAQ ( ); |
388 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 388 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
389 | dev = new Zaurus ( ); | 389 | dev = new Zaurus ( ); |
390 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 390 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
391 | dev = new SIMpad ( ); | 391 | dev = new SIMpad ( ); |
392 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 392 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
393 | dev = new Ramses ( ); | 393 | dev = new Ramses ( ); |
394 | else | 394 | else |
395 | dev = new ODevice ( ); | 395 | dev = new ODevice ( ); |
396 | 396 | ||
397 | dev-> init ( ); | 397 | dev-> init ( ); |
398 | } | 398 | } |
399 | return dev; | 399 | return dev; |
400 | } | 400 | } |
401 | 401 | ||
402 | 402 | ||
403 | /************************************************** | 403 | /************************************************** |
404 | * | 404 | * |
405 | * common | 405 | * common |
406 | * | 406 | * |
407 | **************************************************/ | 407 | **************************************************/ |
408 | 408 | ||
409 | 409 | ||
410 | ODevice::ODevice ( ) | 410 | ODevice::ODevice ( ) |
411 | { | 411 | { |
412 | d = new ODeviceData; | 412 | d = new ODeviceData; |
413 | 413 | ||
414 | d-> m_modelstr = "Unknown"; | 414 | d-> m_modelstr = "Unknown"; |
415 | d-> m_model = Model_Unknown; | 415 | d-> m_model = Model_Unknown; |
416 | d-> m_vendorstr = "Unknown"; | 416 | d-> m_vendorstr = "Unknown"; |
417 | d-> m_vendor = Vendor_Unknown; | 417 | d-> m_vendor = Vendor_Unknown; |
418 | d-> m_systemstr = "Unknown"; | 418 | d-> m_systemstr = "Unknown"; |
419 | d-> m_system = System_Unknown; | 419 | d-> m_system = System_Unknown; |
420 | d-> m_sysverstr = "0.0"; | 420 | d-> m_sysverstr = "0.0"; |
421 | d-> m_rotation = Rot0; | 421 | d-> m_rotation = Rot0; |
422 | d-> m_direction = CW; | 422 | d-> m_direction = CW; |
423 | 423 | ||
424 | d-> m_holdtime = 1000; // 1000ms | 424 | d-> m_holdtime = 1000; // 1000ms |
425 | d-> m_buttons = 0; | 425 | d-> m_buttons = 0; |
426 | } | 426 | } |
427 | 427 | ||
428 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 428 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
429 | { | 429 | { |
430 | if ( msg == "deviceButtonMappingChanged()" ) { | 430 | if ( msg == "deviceButtonMappingChanged()" ) { |
431 | reloadButtonMapping ( ); | 431 | reloadButtonMapping ( ); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | void ODevice::init ( ) | 435 | void ODevice::init ( ) |
436 | { | 436 | { |
437 | } | 437 | } |
438 | 438 | ||
439 | /** | 439 | /** |
440 | * This method initialises the button mapping | 440 | * This method initialises the button mapping |
441 | */ | 441 | */ |
442 | void ODevice::initButtons ( ) | 442 | void ODevice::initButtons ( ) |
443 | { | 443 | { |
444 | if ( d-> m_buttons ) | 444 | if ( d-> m_buttons ) |
445 | return; | 445 | return; |
446 | 446 | ||
447 | // Simulation uses iPAQ 3660 device buttons | 447 | // Simulation uses iPAQ 3660 device buttons |
448 | 448 | ||
449 | qDebug ( "init Buttons" ); | 449 | qDebug ( "init Buttons" ); |
450 | d-> m_buttons = new QValueList <ODeviceButton>; | 450 | d-> m_buttons = new QValueList <ODeviceButton>; |
451 | 451 | ||
452 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 452 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
453 | i_button *ib = ipaq_buttons + i; | 453 | i_button *ib = ipaq_buttons + i; |
454 | ODeviceButton b; | 454 | ODeviceButton b; |
455 | 455 | ||
456 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 456 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
457 | b. setKeycode ( ib-> code ); | 457 | b. setKeycode ( ib-> code ); |
458 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 458 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
459 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 459 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
460 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 460 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
461 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 461 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
462 | d-> m_buttons-> append ( b ); | 462 | d-> m_buttons-> append ( b ); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | reloadButtonMapping ( ); | 465 | reloadButtonMapping ( ); |
466 | 466 | ||
467 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 467 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
468 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 468 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
469 | } | 469 | } |
470 | 470 | ||
471 | ODevice::~ODevice ( ) | 471 | ODevice::~ODevice ( ) |
472 | { | 472 | { |
473 | delete d; | 473 | delete d; |
474 | } | 474 | } |
475 | 475 | ||
476 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 476 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
477 | { | 477 | { |
478 | return false; | 478 | return false; |
479 | } | 479 | } |
480 | 480 | ||
481 | //#include <linux/apm_bios.h> | 481 | //#include <linux/apm_bios.h> |
482 | 482 | ||
483 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 483 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
484 | 484 | ||
485 | /** | 485 | /** |
486 | * This method will try to suspend the device | 486 | * This method will try to suspend the device |
487 | * It only works if the user is the QWS Server and the apm application | 487 | * It only works if the user is the QWS Server and the apm application |
488 | * is installed. | 488 | * is installed. |
489 | * It tries to suspend and then waits some time cause some distributions | 489 | * It tries to suspend and then waits some time cause some distributions |
490 | * do have asynchronus apm implementations. | 490 | * do have asynchronus apm implementations. |
491 | * This method will either fail and return false or it'll suspend the | 491 | * This method will either fail and return false or it'll suspend the |
492 | * device and return once the device got woken up | 492 | * device and return once the device got woken up |
493 | * | 493 | * |
494 | * @return if the device got suspended | 494 | * @return if the device got suspended |
495 | */ | 495 | */ |
496 | bool ODevice::suspend ( ) | 496 | bool ODevice::suspend ( ) |
497 | { | 497 | { |
498 | qDebug("ODevice::suspend"); | 498 | qDebug("ODevice::suspend"); |
499 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 499 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
500 | return false; | 500 | return false; |
501 | 501 | ||
502 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 502 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
503 | return false; | 503 | return false; |
504 | 504 | ||
505 | bool res = false; | 505 | bool res = false; |
506 | 506 | ||
507 | struct timeval tvs, tvn; | 507 | struct timeval tvs, tvn; |
508 | ::gettimeofday ( &tvs, 0 ); | 508 | ::gettimeofday ( &tvs, 0 ); |
509 | 509 | ||
510 | ::sync ( ); // flush fs caches | 510 | ::sync ( ); // flush fs caches |
511 | res = ( ::system ( "apm --suspend" ) == 0 ); | 511 | res = ( ::system ( "apm --suspend" ) == 0 ); |
512 | 512 | ||
513 | // This is needed because the iPAQ apm implementation is asynchronous and we | 513 | // This is needed because the iPAQ apm implementation is asynchronous and we |
514 | // can not be sure when exactly the device is really suspended | 514 | // can not be sure when exactly the device is really suspended |
515 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 515 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
516 | 516 | ||
517 | if ( res ) { | 517 | if ( res ) { |
518 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 518 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
519 | ::usleep ( 200 * 1000 ); | 519 | ::usleep ( 200 * 1000 ); |
520 | ::gettimeofday ( &tvn, 0 ); | 520 | ::gettimeofday ( &tvn, 0 ); |
521 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 521 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
522 | } | 522 | } |
523 | 523 | ||
524 | return res; | 524 | return res; |
525 | } | 525 | } |
526 | 526 | ||
527 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 527 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
528 | 528 | ||
529 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 529 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
530 | 530 | ||
531 | /* VESA Blanking Levels */ | 531 | /* VESA Blanking Levels */ |
532 | #define VESA_NO_BLANKING 0 | 532 | #define VESA_NO_BLANKING 0 |
533 | #define VESA_VSYNC_SUSPEND 1 | 533 | #define VESA_VSYNC_SUSPEND 1 |
534 | #define VESA_HSYNC_SUSPEND 2 | 534 | #define VESA_HSYNC_SUSPEND 2 |
535 | #define VESA_POWERDOWN 3 | 535 | #define VESA_POWERDOWN 3 |
536 | 536 | ||
537 | /** | 537 | /** |
538 | * This sets the display on or off | 538 | * This sets the display on or off |
539 | */ | 539 | */ |
540 | bool ODevice::setDisplayStatus ( bool on ) | 540 | bool ODevice::setDisplayStatus ( bool on ) |
541 | { | 541 | { |
542 | qDebug("ODevice::setDisplayStatus(%d)", on); | 542 | qDebug("ODevice::setDisplayStatus(%d)", on); |
543 | 543 | ||
544 | if ( d-> m_model == Model_Unknown ) | 544 | if ( d-> m_model == Model_Unknown ) |
545 | return false; | 545 | return false; |
546 | 546 | ||
547 | bool res = false; | 547 | bool res = false; |
548 | int fd; | 548 | int fd; |
549 | 549 | ||
550 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 550 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
551 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 551 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
552 | ::close ( fd ); | 552 | ::close ( fd ); |
553 | } | 553 | } |
554 | return res; | 554 | return res; |
555 | } | 555 | } |
556 | 556 | ||
557 | /** | 557 | /** |
558 | * This sets the display brightness | 558 | * This sets the display brightness |
559 | * | ||
560 | * @param p The brightness to be set on a scale from 0 to 255 | ||
559 | * @return success or failure | 561 | * @return success or failure |
560 | */ | 562 | */ |
561 | bool ODevice::setDisplayBrightness ( int p) | 563 | bool ODevice::setDisplayBrightness ( int p) |
562 | { | 564 | { |
563 | Q_UNUSED( p ) | 565 | Q_UNUSED( p ) |
564 | return false; | 566 | return false; |
565 | } | 567 | } |
566 | 568 | ||
567 | /** | 569 | /** |
568 | * @return return the max value for the brightness settings slider | 570 | * @return returns the number of steppings on the brightness slider |
571 | * in the Light-'n-Power settings. | ||
569 | */ | 572 | */ |
570 | int ODevice::displayBrightnessResolution ( ) const | 573 | int ODevice::displayBrightnessResolution ( ) const |
571 | { | 574 | { |
572 | return 16; | 575 | return 16; |
573 | } | 576 | } |
574 | 577 | ||
575 | /** | 578 | /** |
576 | * This sets the display contrast | 579 | * This sets the display contrast |
580 | * @param p The contrast to be set on a scale from 0 to 255 | ||
577 | * @return success or failure | 581 | * @return success or failure |
578 | */ | 582 | */ |
579 | bool ODevice::setDisplayContrast ( int p) | 583 | bool ODevice::setDisplayContrast ( int p) |
580 | { | 584 | { |
581 | Q_UNUSED( p ) | 585 | Q_UNUSED( p ) |
582 | return false; | 586 | return false; |
583 | } | 587 | } |
584 | 588 | ||
585 | /** | 589 | /** |
586 | * @return return the max value for the brightness settings slider | 590 | * @return return the max value for the brightness settings slider |
587 | * or 0 if the device doesn't support setting of a contrast | 591 | * or 0 if the device doesn't support setting of a contrast |
588 | */ | 592 | */ |
589 | int ODevice::displayContrastResolution ( ) const | 593 | int ODevice::displayContrastResolution ( ) const |
590 | { | 594 | { |
591 | return 0; | 595 | return 0; |
592 | } | 596 | } |
593 | 597 | ||
594 | /** | 598 | /** |
595 | * This returns the vendor as string | 599 | * This returns the vendor as string |
596 | * @return Vendor as QString | 600 | * @return Vendor as QString |
597 | */ | 601 | */ |
598 | QString ODevice::vendorString ( ) const | 602 | QString ODevice::vendorString ( ) const |
599 | { | 603 | { |
600 | return d-> m_vendorstr; | 604 | return d-> m_vendorstr; |
601 | } | 605 | } |
602 | 606 | ||
603 | /** | 607 | /** |
604 | * This returns the vendor as one of the values of OVendor | 608 | * This returns the vendor as one of the values of OVendor |
605 | * @return OVendor | 609 | * @return OVendor |
606 | */ | 610 | */ |
607 | OVendor ODevice::vendor ( ) const | 611 | OVendor ODevice::vendor ( ) const |
608 | { | 612 | { |
609 | return d-> m_vendor; | 613 | return d-> m_vendor; |
610 | } | 614 | } |
611 | 615 | ||
612 | /** | 616 | /** |
613 | * This returns the model as a string | 617 | * This returns the model as a string |
614 | * @return A string representing the model | 618 | * @return A string representing the model |
615 | */ | 619 | */ |
616 | QString ODevice::modelString ( ) const | 620 | QString ODevice::modelString ( ) const |
617 | { | 621 | { |
618 | return d-> m_modelstr; | 622 | return d-> m_modelstr; |
619 | } | 623 | } |
620 | 624 | ||
621 | /** | 625 | /** |
622 | * This does return the OModel used | 626 | * This does return the OModel used |
623 | */ | 627 | */ |
624 | OModel ODevice::model ( ) const | 628 | OModel ODevice::model ( ) const |
625 | { | 629 | { |
626 | return d-> m_model; | 630 | return d-> m_model; |
627 | } | 631 | } |
628 | 632 | ||
629 | /** | 633 | /** |
630 | * This does return the systen name | 634 | * This does return the systen name |
631 | */ | 635 | */ |
632 | QString ODevice::systemString ( ) const | 636 | QString ODevice::systemString ( ) const |
633 | { | 637 | { |
634 | return d-> m_systemstr; | 638 | return d-> m_systemstr; |
635 | } | 639 | } |
636 | 640 | ||
637 | /** | 641 | /** |
638 | * Return System as OSystem value | 642 | * Return System as OSystem value |
639 | */ | 643 | */ |
640 | OSystem ODevice::system ( ) const | 644 | OSystem ODevice::system ( ) const |
641 | { | 645 | { |
642 | return d-> m_system; | 646 | return d-> m_system; |
643 | } | 647 | } |
644 | 648 | ||
645 | /** | 649 | /** |
646 | * @return the version string of the base system | 650 | * @return the version string of the base system |
647 | */ | 651 | */ |
648 | QString ODevice::systemVersionString ( ) const | 652 | QString ODevice::systemVersionString ( ) const |
649 | { | 653 | { |
650 | return d-> m_sysverstr; | 654 | return d-> m_sysverstr; |
651 | } | 655 | } |
652 | 656 | ||
653 | /** | 657 | /** |
654 | * @return the current Transformation | 658 | * @return the current Transformation |
655 | */ | 659 | */ |
656 | Transformation ODevice::rotation ( ) const | 660 | Transformation ODevice::rotation ( ) const |
657 | { | 661 | { |
658 | return d-> m_rotation; | 662 | return d-> m_rotation; |
659 | } | 663 | } |
660 | 664 | ||
661 | /** | 665 | /** |
662 | * @return the current rotation direction | 666 | * @return the current rotation direction |
663 | */ | 667 | */ |
664 | ODirection ODevice::direction ( ) const | 668 | ODirection ODevice::direction ( ) const |
665 | { | 669 | { |
666 | return d-> m_direction; | 670 | return d-> m_direction; |
667 | } | 671 | } |
668 | 672 | ||
669 | /** | 673 | /** |
670 | * This plays an alarmSound | 674 | * This plays an alarmSound |
671 | */ | 675 | */ |
672 | void ODevice::alarmSound ( ) | 676 | void ODevice::alarmSound ( ) |
673 | { | 677 | { |
674 | #ifndef QT_NO_SOUND | 678 | #ifndef QT_NO_SOUND |
675 | static Sound snd ( "alarm" ); | 679 | static Sound snd ( "alarm" ); |
676 | 680 | ||
677 | if ( snd. isFinished ( )) | 681 | if ( snd. isFinished ( )) |
678 | snd. play ( ); | 682 | snd. play ( ); |
679 | #endif | 683 | #endif |
680 | } | 684 | } |
681 | 685 | ||
682 | /** | 686 | /** |
683 | * This plays a key sound | 687 | * This plays a key sound |
684 | */ | 688 | */ |
685 | void ODevice::keySound ( ) | 689 | void ODevice::keySound ( ) |
686 | { | 690 | { |
687 | #ifndef QT_NO_SOUND | 691 | #ifndef QT_NO_SOUND |
688 | static Sound snd ( "keysound" ); | 692 | static Sound snd ( "keysound" ); |
689 | 693 | ||
690 | if ( snd. isFinished ( )) | 694 | if ( snd. isFinished ( )) |
691 | snd. play ( ); | 695 | snd. play ( ); |
692 | #endif | 696 | #endif |
693 | } | 697 | } |
694 | 698 | ||
695 | /** | 699 | /** |
696 | * This plays a touch sound | 700 | * This plays a touch sound |
697 | */ | 701 | */ |
698 | void ODevice::touchSound ( ) | 702 | void ODevice::touchSound ( ) |
699 | { | 703 | { |
700 | #ifndef QT_NO_SOUND | 704 | #ifndef QT_NO_SOUND |
701 | static Sound snd ( "touchsound" ); | 705 | static Sound snd ( "touchsound" ); |
702 | 706 | ||
703 | if ( snd. isFinished ( )) | 707 | if ( snd. isFinished ( )) |
704 | snd. play ( ); | 708 | snd. play ( ); |
705 | #endif | 709 | #endif |
706 | } | 710 | } |
707 | 711 | ||
708 | /** | 712 | /** |
709 | * This method will return a list of leds | 713 | * This method will return a list of leds |
710 | * available on this device | 714 | * available on this device |
711 | * @return a list of LEDs. | 715 | * @return a list of LEDs. |
712 | */ | 716 | */ |
713 | QValueList <OLed> ODevice::ledList ( ) const | 717 | QValueList <OLed> ODevice::ledList ( ) const |
714 | { | 718 | { |
715 | return QValueList <OLed> ( ); | 719 | return QValueList <OLed> ( ); |
716 | } | 720 | } |
717 | 721 | ||
718 | /** | 722 | /** |
719 | * This does return the state of the LEDs | 723 | * This does return the state of the LEDs |
720 | */ | 724 | */ |
721 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 725 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
722 | { | 726 | { |
723 | return QValueList <OLedState> ( ); | 727 | return QValueList <OLedState> ( ); |
724 | } | 728 | } |
725 | 729 | ||
726 | /** | 730 | /** |
727 | * @return the state for a given OLed | 731 | * @return the state for a given OLed |
728 | */ | 732 | */ |
729 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 733 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
730 | { | 734 | { |
731 | return Led_Off; | 735 | return Led_Off; |
732 | } | 736 | } |
733 | 737 | ||
734 | /** | 738 | /** |
735 | * Set the state for a LED | 739 | * Set the state for a LED |
736 | * @param which Which OLed to use | 740 | * @param which Which OLed to use |
737 | * @param st The state to set | 741 | * @param st The state to set |
738 | * @return success or failure | 742 | * @return success or failure |
739 | */ | 743 | */ |
740 | bool ODevice::setLedState ( OLed which, OLedState st ) | 744 | bool ODevice::setLedState ( OLed which, OLedState st ) |
741 | { | 745 | { |
742 | Q_UNUSED( which ) | 746 | Q_UNUSED( which ) |
743 | Q_UNUSED( st ) | 747 | Q_UNUSED( st ) |
744 | return false; | 748 | return false; |
745 | } | 749 | } |
746 | 750 | ||
747 | /** | 751 | /** |
748 | * @return if the device has a light sensor | 752 | * @return if the device has a light sensor |
749 | */ | 753 | */ |
750 | bool ODevice::hasLightSensor ( ) const | 754 | bool ODevice::hasLightSensor ( ) const |
751 | { | 755 | { |
752 | return false; | 756 | return false; |
753 | } | 757 | } |
754 | 758 | ||
755 | /** | 759 | /** |
756 | * @return a value from the light senso | 760 | * @return a value from the light senso |
757 | */ | 761 | */ |
758 | int ODevice::readLightSensor ( ) | 762 | int ODevice::readLightSensor ( ) |
759 | { | 763 | { |
760 | return -1; | 764 | return -1; |
761 | } | 765 | } |
762 | 766 | ||
763 | /** | 767 | /** |
764 | * @return the light sensor resolution whatever that is ;) | 768 | * @return the light sensor resolution whatever that is ;) |
765 | */ | 769 | */ |
766 | int ODevice::lightSensorResolution ( ) const | 770 | int ODevice::lightSensorResolution ( ) const |
767 | { | 771 | { |
768 | return 0; | 772 | return 0; |
@@ -1881,218 +1885,218 @@ bool SIMpad::setDisplayBrightness ( int bright ) | |||
1881 | int fd; | 1885 | int fd; |
1882 | 1886 | ||
1883 | if ( bright > 255 ) | 1887 | if ( bright > 255 ) |
1884 | bright = 255; | 1888 | bright = 255; |
1885 | if ( bright < 0 ) | 1889 | if ( bright < 0 ) |
1886 | bright = 0; | 1890 | bright = 0; |
1887 | 1891 | ||
1888 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 1892 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
1889 | int value = 255 - bright; | 1893 | int value = 255 - bright; |
1890 | const int mask = SIMPAD_BACKLIGHT_MASK; | 1894 | const int mask = SIMPAD_BACKLIGHT_MASK; |
1891 | value = value << 8; | 1895 | value = value << 8; |
1892 | value += mask; | 1896 | value += mask; |
1893 | char writeCommand[100]; | 1897 | char writeCommand[100]; |
1894 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 1898 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
1895 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 1899 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
1896 | ::close ( fd ); | 1900 | ::close ( fd ); |
1897 | } | 1901 | } |
1898 | return res; | 1902 | return res; |
1899 | } | 1903 | } |
1900 | 1904 | ||
1901 | 1905 | ||
1902 | int SIMpad::displayBrightnessResolution ( ) const | 1906 | int SIMpad::displayBrightnessResolution ( ) const |
1903 | { | 1907 | { |
1904 | switch ( model ( )) { | 1908 | switch ( model ( )) { |
1905 | case Model_SIMpad_CL4: | 1909 | case Model_SIMpad_CL4: |
1906 | case Model_SIMpad_SL4: | 1910 | case Model_SIMpad_SL4: |
1907 | case Model_SIMpad_SLC: | 1911 | case Model_SIMpad_SLC: |
1908 | case Model_SIMpad_TSinus: | 1912 | case Model_SIMpad_TSinus: |
1909 | return 255; //TODO find out if this is save | 1913 | return 255; //TODO find out if this is save |
1910 | 1914 | ||
1911 | default: | 1915 | default: |
1912 | return 2; | 1916 | return 2; |
1913 | } | 1917 | } |
1914 | } | 1918 | } |
1915 | 1919 | ||
1916 | /************************************************** | 1920 | /************************************************** |
1917 | * | 1921 | * |
1918 | * Ramses | 1922 | * Ramses |
1919 | * | 1923 | * |
1920 | **************************************************/ | 1924 | **************************************************/ |
1921 | 1925 | ||
1922 | void Ramses::init() | 1926 | void Ramses::init() |
1923 | { | 1927 | { |
1924 | d->m_vendorstr = "M und N"; | 1928 | d->m_vendorstr = "M und N"; |
1925 | d->m_vendor = Vendor_MundN; | 1929 | d->m_vendor = Vendor_MundN; |
1926 | 1930 | ||
1927 | QFile f("/proc/sys/board/ramses"); | 1931 | QFile f("/proc/sys/board/ramses"); |
1928 | 1932 | ||
1929 | d->m_modelstr = "Ramses"; | 1933 | d->m_modelstr = "Ramses"; |
1930 | d->m_model = Model_Ramses_MNCI; | 1934 | d->m_model = Model_Ramses_MNCI; |
1931 | 1935 | ||
1932 | d->m_rotation = Rot0; | 1936 | d->m_rotation = Rot0; |
1933 | d->m_holdtime = 1000; | 1937 | d->m_holdtime = 1000; |
1934 | 1938 | ||
1935 | f.setName("/etc/oz_version"); | 1939 | f.setName("/etc/oz_version"); |
1936 | 1940 | ||
1937 | if (f.open(IO_ReadOnly)) { | 1941 | if (f.open(IO_ReadOnly)) { |
1938 | d->m_systemstr = "OpenEmbedded/Ramses"; | 1942 | d->m_systemstr = "OpenEmbedded/Ramses"; |
1939 | d->m_system = System_OpenZaurus; | 1943 | d->m_system = System_OpenZaurus; |
1940 | 1944 | ||
1941 | QTextStream ts(&f); | 1945 | QTextStream ts(&f); |
1942 | ts.setDevice(&f); | 1946 | ts.setDevice(&f); |
1943 | d->m_sysverstr = ts.readLine(); | 1947 | d->m_sysverstr = ts.readLine(); |
1944 | f.close(); | 1948 | f.close(); |
1945 | } | 1949 | } |
1946 | 1950 | ||
1947 | m_power_timer = 0; | 1951 | m_power_timer = 0; |
1948 | 1952 | ||
1949 | } | 1953 | } |
1950 | 1954 | ||
1951 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 1955 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
1952 | { | 1956 | { |
1953 | Q_UNUSED( keycode ); | 1957 | Q_UNUSED( keycode ); |
1954 | Q_UNUSED( modifiers ); | 1958 | Q_UNUSED( modifiers ); |
1955 | Q_UNUSED( isPress ); | 1959 | Q_UNUSED( isPress ); |
1956 | Q_UNUSED( autoRepeat ); | 1960 | Q_UNUSED( autoRepeat ); |
1957 | return false; | 1961 | return false; |
1958 | } | 1962 | } |
1959 | 1963 | ||
1960 | void Ramses::timerEvent(QTimerEvent *) | 1964 | void Ramses::timerEvent(QTimerEvent *) |
1961 | { | 1965 | { |
1962 | killTimer(m_power_timer); | 1966 | killTimer(m_power_timer); |
1963 | m_power_timer = 0; | 1967 | m_power_timer = 0; |
1964 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 1968 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
1965 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 1969 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
1966 | } | 1970 | } |
1967 | 1971 | ||
1968 | 1972 | ||
1969 | bool Ramses::setSoftSuspend(bool soft) | 1973 | bool Ramses::setSoftSuspend(bool soft) |
1970 | { | 1974 | { |
1971 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 1975 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
1972 | #if 0 | 1976 | #if 0 |
1973 | bool res = false; | 1977 | bool res = false; |
1974 | int fd; | 1978 | int fd; |
1975 | 1979 | ||
1976 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 1980 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
1977 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 1981 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
1978 | 1982 | ||
1979 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 1983 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
1980 | 1984 | ||
1981 | if (sources >= 0) { | 1985 | if (sources >= 0) { |
1982 | if (soft) | 1986 | if (soft) |
1983 | sources &= ~APM_EVT_POWER_BUTTON; | 1987 | sources &= ~APM_EVT_POWER_BUTTON; |
1984 | else | 1988 | else |
1985 | sources |= APM_EVT_POWER_BUTTON; | 1989 | sources |= APM_EVT_POWER_BUTTON; |
1986 | 1990 | ||
1987 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | 1991 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources |
1988 | res = true; | 1992 | res = true; |
1989 | else | 1993 | else |
1990 | perror("APM_IOCGEVTSRC"); | 1994 | perror("APM_IOCGEVTSRC"); |
1991 | } | 1995 | } |
1992 | else | 1996 | else |
1993 | perror("APM_IOCGEVTSRC"); | 1997 | perror("APM_IOCGEVTSRC"); |
1994 | 1998 | ||
1995 | ::close(fd); | 1999 | ::close(fd); |
1996 | } | 2000 | } |
1997 | else | 2001 | else |
1998 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | 2002 | perror("/dev/apm_bios or /dev/misc/apm_bios"); |
1999 | 2003 | ||
2000 | return res; | 2004 | return res; |
2001 | #else | 2005 | #else |
2002 | return true; | 2006 | return true; |
2003 | #endif | 2007 | #endif |
2004 | } | 2008 | } |
2005 | 2009 | ||
2006 | bool Ramses::suspend ( ) | 2010 | bool Ramses::suspend ( ) |
2007 | { | 2011 | { |
2008 | qDebug("Ramses::suspend"); | 2012 | qDebug("Ramses::suspend"); |
2009 | } | 2013 | } |
2010 | 2014 | ||
2011 | /** | 2015 | /** |
2012 | * This sets the display on or off | 2016 | * This sets the display on or off |
2013 | */ | 2017 | */ |
2014 | bool Ramses::setDisplayStatus(bool on) | 2018 | bool Ramses::setDisplayStatus(bool on) |
2015 | { | 2019 | { |
2016 | qDebug("Ramses::setDisplayStatus(%d)", on); | 2020 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2017 | #if 0 | 2021 | #if 0 |
2018 | bool res = false; | 2022 | bool res = false; |
2019 | int fd; | 2023 | int fd; |
2020 | 2024 | ||
2021 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 2025 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2022 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2026 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2023 | ::close(fd); | 2027 | ::close(fd); |
2024 | } | 2028 | } |
2025 | return res; | 2029 | return res; |
2026 | #else | 2030 | #else |
2027 | return true; | 2031 | return true; |
2028 | #endif | 2032 | #endif |
2029 | } | 2033 | } |
2030 | 2034 | ||
2031 | 2035 | ||
2032 | /* | 2036 | /* |
2033 | * We get something between 0..255 into us | 2037 | * We get something between 0..255 into us |
2034 | */ | 2038 | */ |
2035 | bool Ramses::setDisplayBrightness(int bright) | 2039 | bool Ramses::setDisplayBrightness(int bright) |
2036 | { | 2040 | { |
2037 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2041 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2038 | bool res = false; | 2042 | bool res = false; |
2039 | int fd; | 2043 | int fd; |
2040 | 2044 | ||
2041 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2045 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2042 | 2046 | ||
2043 | if (bright > 255 ) | 2047 | if (bright > 255 ) |
2044 | bright = 255; | 2048 | bright = 255; |
2045 | if (bright < 0) | 2049 | if (bright < 0) |
2046 | bright = 0; | 2050 | bright = 0; |
2047 | bright = 500-(bright * 500 / 255); | 2051 | bright = 500-(bright * 500 / 255); |
2048 | 2052 | ||
2049 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2053 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2050 | qDebug(" %d -> pwm1", bright); | 2054 | qDebug(" %d -> pwm1", bright); |
2051 | char writeCommand[100]; | 2055 | char writeCommand[100]; |
2052 | const int count = sprintf(writeCommand, "%d\n", bright); | 2056 | const int count = sprintf(writeCommand, "%d\n", bright); |
2053 | res = (::write(fd, writeCommand, count) != -1); | 2057 | res = (::write(fd, writeCommand, count) != -1); |
2054 | ::close(fd); | 2058 | ::close(fd); |
2055 | } else { | 2059 | } else { |
2056 | qWarning("no write"); | 2060 | qWarning("no write"); |
2057 | } | 2061 | } |
2058 | return res; | 2062 | return res; |
2059 | } | 2063 | } |
2060 | 2064 | ||
2061 | 2065 | ||
2062 | int Ramses::displayBrightnessResolution() const | 2066 | int Ramses::displayBrightnessResolution() const |
2063 | { | 2067 | { |
2064 | return 32; | 2068 | return 32; |
2065 | } | 2069 | } |
2066 | 2070 | ||
2067 | bool Ramses::setDisplayContrast(int contr) | 2071 | bool Ramses::setDisplayContrast(int contr) |
2068 | { | 2072 | { |
2069 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2073 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2070 | bool res = false; | 2074 | bool res = false; |
2071 | int fd; | 2075 | int fd; |
2072 | 2076 | ||
2073 | // pwm0 contrast: 35 steps 65..100 (dunkel->hell) | 2077 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2074 | 2078 | ||
2075 | if (contr > 255 ) | 2079 | if (contr > 255 ) |
2076 | contr = 255; | 2080 | contr = 255; |
2077 | if (contr < 0) | 2081 | if (contr < 0) |
2078 | contr = 0; | 2082 | contr = 0; |
2079 | contr = 65 + (contr * 350 / 255); | 2083 | contr = 90 - (contr * 20 / 255); |
2080 | 2084 | ||
2081 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2085 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2082 | qDebug(" %d -> pwm0", contr); | 2086 | qDebug(" %d -> pwm0", contr); |
2083 | char writeCommand[100]; | 2087 | char writeCommand[100]; |
2084 | const int count = sprintf(writeCommand, "%d\n", contr); | 2088 | const int count = sprintf(writeCommand, "%d\n", contr); |
2085 | res = (::write(fd, writeCommand, count) != -1); | 2089 | res = (::write(fd, writeCommand, count) != -1); |
2086 | res = true; | 2090 | res = true; |
2087 | ::close(fd); | 2091 | ::close(fd); |
2088 | } else { | 2092 | } else { |
2089 | qWarning("no write"); | 2093 | qWarning("no write"); |
2090 | } | 2094 | } |
2091 | return res; | 2095 | return res; |
2092 | } | 2096 | } |
2093 | 2097 | ||
2094 | 2098 | ||
2095 | int Ramses::displayContrastResolution() const | 2099 | int Ramses::displayContrastResolution() const |
2096 | { | 2100 | { |
2097 | return 32; | 2101 | return 20; |
2098 | } | 2102 | } |