summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authoreilers <eilers>2003-08-08 15:09:29 (UTC)
committer eilers <eilers>2003-08-08 15:09:29 (UTC)
commitb87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16 (patch) (unidiff)
treeb0f96db67cfb1b9d2476530ecec9a2ba6eacbab1 /libopie/odevice.cpp
parent14d394e6c107b037a09a31a92605034fe50f7813 (diff)
downloadopie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.zip
opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.gz
opie-b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16.tar.bz2
Merging all changes from BRANCH_1_0.
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
@@ -443,64 +443,67 @@ void ODevice::init ( )
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
@@ -756,65 +759,65 @@ bool ODevice::setLedState ( OLed which, OLedState st )
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;
@@ -891,69 +894,67 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &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;
@@ -1619,65 +1620,64 @@ bool Zaurus::setSoftSuspend ( bool soft )
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;
@@ -1860,284 +1860,299 @@ void SIMpad::alarmSound ( )
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}