summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp12
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
@@ -463,210 +463,214 @@ void ODevice::initButtons ( )
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
471ODevice::~ODevice ( ) 471ODevice::~ODevice ( )
472{ 472{
473 delete d; 473 delete d;
474} 474}
475 475
476bool ODevice::setSoftSuspend ( bool /*soft*/ ) 476bool 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 */
496bool ODevice::suspend ( ) 496bool 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 */
540bool ODevice::setDisplayStatus ( bool on ) 540bool 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 */
561bool ODevice::setDisplayBrightness ( int p) 563bool 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 */
570int ODevice::displayBrightnessResolution ( ) const 573int 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 */
579bool ODevice::setDisplayContrast ( int p) 583bool 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 */
589int ODevice::displayContrastResolution ( ) const 593int 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 */
598QString ODevice::vendorString ( ) const 602QString 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 */
607OVendor ODevice::vendor ( ) const 611OVendor 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 */
616QString ODevice::modelString ( ) const 620QString 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 */
624OModel ODevice::model ( ) const 628OModel 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 */
632QString ODevice::systemString ( ) const 636QString 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 */
640OSystem ODevice::system ( ) const 644OSystem 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 */
648QString ODevice::systemVersionString ( ) const 652QString 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 */
656Transformation ODevice::rotation ( ) const 660Transformation 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 */
664ODirection ODevice::direction ( ) const 668ODirection 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 */
672void ODevice::alarmSound ( ) 676void ODevice::alarmSound ( )
@@ -1977,122 +1981,122 @@ bool Ramses::setSoftSuspend(bool soft)
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
2006bool Ramses::suspend ( ) 2010bool 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 */
2014bool Ramses::setDisplayStatus(bool on) 2018bool 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*/
2035bool Ramses::setDisplayBrightness(int bright) 2039bool 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
2062int Ramses::displayBrightnessResolution() const 2066int Ramses::displayBrightnessResolution() const
2063{ 2067{
2064 return 32; 2068 return 32;
2065} 2069}
2066 2070
2067bool Ramses::setDisplayContrast(int contr) 2071bool 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
2095int Ramses::displayContrastResolution() const 2099int Ramses::displayContrastResolution() const
2096{ 2100{
2097 return 32; 2101 return 20;
2098} 2102}