summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-30 02:17:25 (UTC)
committer mickeyl <mickeyl>2003-12-30 02:17:25 (UTC)
commitb53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a (patch) (unidiff)
tree98db0a0053c53e98ba758773f80ad8e14c9564c9
parentb636d3d91e8456b22bc450b3d7f3a862b7f615a9 (diff)
downloadopie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.zip
opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.tar.gz
opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.tar.bz2
fix a problem in the c7x0 backlight handling...
Bah! Got confused by the input interval for ODevice::setDisplayBrightness() (once) again - it has been ridiculous to scale that down from [0-255] to the actual interval since the day we invented ODevice::displayBrightnessResolution(). I'm going to remove that antique cruft soon.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index bc09e92..82a0099 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1510,123 +1510,123 @@ int iPAQ::lightSensorResolution ( ) const
1510 return 256; 1510 return 256;
1511} 1511}
1512 1512
1513/************************************************** 1513/**************************************************
1514 * 1514 *
1515 * Zaurus 1515 * Zaurus
1516 * 1516 *
1517 **************************************************/ 1517 **************************************************/
1518 1518
1519// Check whether this device is the sharp zaurus.. 1519// Check whether this device is the sharp zaurus..
1520// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 1520// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
1521// class up into individual classes. We need three classes 1521// class up into individual classes. We need three classes
1522// 1522//
1523// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 1523// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
1524// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 1524// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
1525// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 1525// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
1526// 1526//
1527// Only question right now is: Do we really need to do it? Because as soon 1527// Only question right now is: Do we really need to do it? Because as soon
1528// as the OpenZaurus kernel is ready, there will be a unified interface for all 1528// as the OpenZaurus kernel is ready, there will be a unified interface for all
1529// Zaurus models (concerning apm, backlight, buttons, etc.) 1529// Zaurus models (concerning apm, backlight, buttons, etc.)
1530// 1530//
1531// Comments? - mickeyl. 1531// Comments? - mickeyl.
1532 1532
1533bool Zaurus::isZaurus() 1533bool Zaurus::isZaurus()
1534{ 1534{
1535 1535
1536 // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! 1536 // If the special devices by embedix exist, it is quite simple: it is a Zaurus !
1537 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ 1537 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
1538 return true; 1538 return true;
1539 } 1539 }
1540 1540
1541 // On non-embedix kernels, we have to look closer. 1541 // On non-embedix kernels, we have to look closer.
1542 bool is_zaurus = false; 1542 bool is_zaurus = false;
1543 QFile f ( "/proc/cpuinfo" ); 1543 QFile f ( "/proc/cpuinfo" );
1544 if ( f. open ( IO_ReadOnly ) ) { 1544 if ( f. open ( IO_ReadOnly ) ) {
1545 QString model; 1545 QString model;
1546 QFile f ( "/proc/cpuinfo" ); 1546 QFile f ( "/proc/cpuinfo" );
1547 1547
1548 QTextStream ts ( &f ); 1548 QTextStream ts ( &f );
1549 QString line; 1549 QString line;
1550 while( line = ts. readLine ( ) ) { 1550 while( line = ts. readLine ( ) ) {
1551 if ( line. left ( 8 ) == "Hardware" ) 1551 if ( line. left ( 8 ) == "Hardware" )
1552 break; 1552 break;
1553 } 1553 }
1554 int loc = line. find ( ":" ); 1554 int loc = line. find ( ":" );
1555 if ( loc != -1 ) 1555 if ( loc != -1 )
1556 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1556 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1557 1557
1558 if ( model == "Sharp-Collie" 1558 if ( model == "Sharp-Collie"
1559 || model == "Collie" 1559 || model == "Collie"
1560 || model == "SHARP Corgi" 1560 || model == "SHARP Corgi"
1561 || model == "SHARP Shepherd" 1561 || model == "SHARP Shepherd"
1562 || model == "SHARP Poodle" 1562 || model == "SHARP Poodle"
1563 || model == "SHARP Husky" 1563 || model == "SHARP Husky"
1564 ) 1564 )
1565 is_zaurus = true; 1565 is_zaurus = true;
1566 1566
1567 } 1567 }
1568 return is_zaurus; 1568 return is_zaurus;
1569} 1569}
1570 1570
1571 1571
1572void Zaurus::init ( ) 1572void Zaurus::init ( )
1573{ 1573{
1574 d-> m_vendorstr = "Sharp"; 1574 d-> m_vendorstr = "Sharp";
1575 d-> m_vendor = Vendor_Sharp; 1575 d-> m_vendor = Vendor_Sharp;
1576 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 1576 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
1577 1577
1578 // QFile f ( "/proc/filesystems" ); 1578 // QFile f ( "/proc/filesystems" );
1579 QString model; 1579 QString model;
1580 1580
1581 // It isn't a good idea to check the system configuration to 1581 // It isn't a good idea to check the system configuration to
1582 // detect the distribution ! 1582 // detect the distribution !
1583 // Otherwise it may happen that any other distribution is detected as openzaurus, just 1583 // Otherwise it may happen that any other distribution is detected as openzaurus, just
1584 // because it uses a jffs2 filesystem.. 1584 // because it uses a jffs2 filesystem..
1585 // (eilers) 1585 // (eilers)
1586 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1586 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1587 QFile f ("/etc/oz_version"); 1587 QFile f ("/etc/oz_version");
1588 if ( f.exists() ){ 1588 if ( f.exists() ){
1589 d-> m_vendorstr = "OpenZaurus Team"; 1589 d-> m_vendorstr = "OpenZaurus Team";
1590 d-> m_systemstr = "OpenZaurus"; 1590 d-> m_systemstr = "OpenZaurus";
1591 d-> m_system = System_OpenZaurus; 1591 d-> m_system = System_OpenZaurus;
1592 1592
1593 if ( f. open ( IO_ReadOnly )) { 1593 if ( f. open ( IO_ReadOnly )) {
1594 QTextStream ts ( &f ); 1594 QTextStream ts ( &f );
1595 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1595 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1596 f. close ( ); 1596 f. close ( );
1597 } 1597 }
1598 1598
1599 // Openzaurus sometimes uses the embedix kernel! 1599 // Openzaurus sometimes uses the embedix kernel!
1600 // => Check whether this is an embedix kernel 1600 // => Check whether this is an embedix kernel
1601 FILE *uname = popen("uname -r", "r"); 1601 FILE *uname = popen("uname -r", "r");
1602 QString line; 1602 QString line;
1603 if ( f.open(IO_ReadOnly, uname) ) { 1603 if ( f.open(IO_ReadOnly, uname) ) {
1604 QTextStream ts ( &f ); 1604 QTextStream ts ( &f );
1605 line = ts. readLine ( ); 1605 line = ts. readLine ( );
1606 int loc = line. find ( "embedix" ); 1606 int loc = line. find ( "embedix" );
1607 if ( loc != -1 ) 1607 if ( loc != -1 )
1608 m_embedix = true; 1608 m_embedix = true;
1609 else 1609 else
1610 m_embedix = false; 1610 m_embedix = false;
1611 f. close ( ); 1611 f. close ( );
1612 } 1612 }
1613 pclose(uname); 1613 pclose(uname);
1614 } 1614 }
1615 else { 1615 else {
1616 d-> m_systemstr = "Zaurus"; 1616 d-> m_systemstr = "Zaurus";
1617 d-> m_system = System_Zaurus; 1617 d-> m_system = System_Zaurus;
1618 } 1618 }
1619 1619
1620 f. setName ( "/proc/cpuinfo" ); 1620 f. setName ( "/proc/cpuinfo" );
1621 if ( f. open ( IO_ReadOnly ) ) { 1621 if ( f. open ( IO_ReadOnly ) ) {
1622 QTextStream ts ( &f ); 1622 QTextStream ts ( &f );
1623 QString line; 1623 QString line;
1624 while( line = ts. readLine ( ) ) { 1624 while( line = ts. readLine ( ) ) {
1625 if ( line. left ( 8 ) == "Hardware" ) 1625 if ( line. left ( 8 ) == "Hardware" )
1626 break; 1626 break;
1627 } 1627 }
1628 int loc = line. find ( ":" ); 1628 int loc = line. find ( ":" );
1629 if ( loc != -1 ) 1629 if ( loc != -1 )
1630 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1630 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1631 } 1631 }
1632 1632
@@ -1651,108 +1651,108 @@ void Zaurus::init ( )
1651 } 1651 }
1652 1652
1653 bool flipstate = false; 1653 bool flipstate = false;
1654 switch ( d-> m_model ) { 1654 switch ( d-> m_model ) {
1655 case Model_Zaurus_SLA300: 1655 case Model_Zaurus_SLA300:
1656 d-> m_rotation = Rot0; 1656 d-> m_rotation = Rot0;
1657 break; 1657 break;
1658 case Model_Zaurus_SLC7x0: 1658 case Model_Zaurus_SLC7x0:
1659 d-> m_rotation = rotation(); 1659 d-> m_rotation = rotation();
1660 d-> m_direction = direction(); 1660 d-> m_direction = direction();
1661 break; 1661 break;
1662 case Model_Zaurus_SLB600: 1662 case Model_Zaurus_SLB600:
1663 case Model_Zaurus_SL5500: 1663 case Model_Zaurus_SL5500:
1664 case Model_Zaurus_SL5000: 1664 case Model_Zaurus_SL5000:
1665 default: 1665 default:
1666 d-> m_rotation = Rot270; 1666 d-> m_rotation = Rot270;
1667 break; 1667 break;
1668 } 1668 }
1669 m_leds [0] = Led_Off; 1669 m_leds [0] = Led_Off;
1670} 1670}
1671 1671
1672void Zaurus::initButtons ( ) 1672void Zaurus::initButtons ( )
1673{ 1673{
1674 if ( d-> m_buttons ) 1674 if ( d-> m_buttons )
1675 return; 1675 return;
1676 1676
1677 d-> m_buttons = new QValueList <ODeviceButton>; 1677 d-> m_buttons = new QValueList <ODeviceButton>;
1678 1678
1679 struct z_button * pz_buttons; 1679 struct z_button * pz_buttons;
1680 int buttoncount; 1680 int buttoncount;
1681 switch ( d-> m_model ) { 1681 switch ( d-> m_model ) {
1682 case Model_Zaurus_SLC7x0: 1682 case Model_Zaurus_SLC7x0:
1683 pz_buttons = z_buttons_c700; 1683 pz_buttons = z_buttons_c700;
1684 buttoncount = ARRAY_SIZE(z_buttons_c700); 1684 buttoncount = ARRAY_SIZE(z_buttons_c700);
1685 break; 1685 break;
1686 default: 1686 default:
1687 pz_buttons = z_buttons; 1687 pz_buttons = z_buttons;
1688 buttoncount = ARRAY_SIZE(z_buttons); 1688 buttoncount = ARRAY_SIZE(z_buttons);
1689 break; 1689 break;
1690 } 1690 }
1691 1691
1692 for ( int i = 0; i < buttoncount; i++ ) { 1692 for ( int i = 0; i < buttoncount; i++ ) {
1693 struct z_button *zb = pz_buttons + i; 1693 struct z_button *zb = pz_buttons + i;
1694 ODeviceButton b; 1694 ODeviceButton b;
1695 1695
1696 b. setKeycode ( zb-> code ); 1696 b. setKeycode ( zb-> code );
1697 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1697 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1698 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1698 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1699 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), 1699 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ),
1700 zb-> fpressedaction )); 1700 zb-> fpressedaction ));
1701 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), 1701 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ),
1702 zb-> fheldaction )); 1702 zb-> fheldaction ));
1703 1703
1704 d-> m_buttons-> append ( b ); 1704 d-> m_buttons-> append ( b );
1705 } 1705 }
1706 1706
1707 reloadButtonMapping ( ); 1707 reloadButtonMapping ( );
1708 1708
1709 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1709 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1710 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), 1710 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )),
1711 this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1711 this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1712} 1712}
1713 1713
1714#include <unistd.h> 1714#include <unistd.h>
1715#include <fcntl.h> 1715#include <fcntl.h>
1716#include <sys/ioctl.h> 1716#include <sys/ioctl.h>
1717 1717
1718//#include <asm/sharp_char.h> // including kernel headers is evil ... 1718//#include <asm/sharp_char.h> // including kernel headers is evil ...
1719 1719
1720#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1720#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1721 1721
1722 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1722 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1723#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1723#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1724 1724
1725#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1725#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1726#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1726#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1727#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1727#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1728 1728
1729/* --- for SHARP_BUZZER device --- */ 1729/* --- for SHARP_BUZZER device --- */
1730 1730
1731 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1731 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1732//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1732//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1733 1733
1734#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1734#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1735#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1735#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1736#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1736#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1737#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1737#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1738#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1738#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1739 1739
1740//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1740//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1741//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1741//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1742 1742
1743//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1743//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1744//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1744//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1745//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1745//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1746//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1746//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1747//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1747//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1748//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1748//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1749//#define SHARP_PDA_APPSTART 9 /* application start */ 1749//#define SHARP_PDA_APPSTART 9 /* application start */
1750//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1750//#define SHARP_PDA_APPQUIT 10 /* application ends */
1751 1751
1752//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1752//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1753//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1753//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1754//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1754//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1755//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1755//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1756// 1756//
1757 1757
1758 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1758 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
@@ -1919,112 +1919,114 @@ bool Zaurus::setLedState ( OLed which, OLedState st )
1919 m_leds [0] = st; 1919 m_leds [0] = st;
1920 return true; 1920 return true;
1921 } 1921 }
1922 } 1922 }
1923 } 1923 }
1924 return false; 1924 return false;
1925} 1925}
1926 1926
1927bool Zaurus::setSoftSuspend ( bool soft ) 1927bool Zaurus::setSoftSuspend ( bool soft )
1928{ 1928{
1929 if (!m_embedix) { 1929 if (!m_embedix) {
1930 /* non-Embedix kernels dont have kernel autosuspend */ 1930 /* non-Embedix kernels dont have kernel autosuspend */
1931 return ODevice::setSoftSuspend( soft ); 1931 return ODevice::setSoftSuspend( soft );
1932 } 1932 }
1933 1933
1934 bool res = false; 1934 bool res = false;
1935 int fd; 1935 int fd;
1936 1936
1937 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1937 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1938 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1938 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1939 1939
1940 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1940 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1941 1941
1942 if ( sources >= 0 ) { 1942 if ( sources >= 0 ) {
1943 if ( soft ) 1943 if ( soft )
1944 sources &= ~APM_EVT_POWER_BUTTON; 1944 sources &= ~APM_EVT_POWER_BUTTON;
1945 else 1945 else
1946 sources |= APM_EVT_POWER_BUTTON; 1946 sources |= APM_EVT_POWER_BUTTON;
1947 1947
1948 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1948 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1949 res = true; 1949 res = true;
1950 else 1950 else
1951 perror ( "APM_IOCGEVTSRC" ); 1951 perror ( "APM_IOCGEVTSRC" );
1952 } 1952 }
1953 else 1953 else
1954 perror ( "APM_IOCGEVTSRC" ); 1954 perror ( "APM_IOCGEVTSRC" );
1955 1955
1956 ::close ( fd ); 1956 ::close ( fd );
1957 } 1957 }
1958 else 1958 else
1959 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1959 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1960 1960
1961 return res; 1961 return res;
1962} 1962}
1963 1963
1964 1964
1965bool Zaurus::setDisplayBrightness ( int bright ) 1965bool Zaurus::setDisplayBrightness ( int bright )
1966{ 1966{
1967 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
1967 bool res = false; 1968 bool res = false;
1968 int fd; 1969 int fd;
1969 1970
1970 if ( bright > 255 ) bright = 255; 1971 if ( bright > 255 ) bright = 255;
1971 if ( bright < 0 ) bright = 0; 1972 if ( bright < 0 ) bright = 0;
1972 1973
1973 if ( m_embedix ) 1974 if ( m_embedix )
1974 { 1975 {
1975 if ( d->m_model == Model_Zaurus_SLC7x0 ) 1976 if ( d->m_model == Model_Zaurus_SLC7x0 )
1976 { 1977 {
1978 //qDebug( "using special treatment for devices with the corgi backlight interface" );
1977 // special treatment for devices with the corgi backlight interface 1979 // special treatment for devices with the corgi backlight interface
1978 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 1980 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
1979 { 1981 {
1980 if ( bright > 0x11 ) bright = 0x11; 1982 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 );
1981 char writeCommand[100]; 1983 char writeCommand[100];
1982 const int count = sprintf( writeCommand, "0x%x\n", bright ); 1984 const int count = sprintf( writeCommand, "0x%x\n", value );
1983 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1985 res = ( ::write ( fd, writeCommand, count ) != -1 );
1984 ::close ( fd ); 1986 ::close ( fd );
1985 } 1987 }
1986 return res; 1988 return res;
1987 } 1989 }
1988 else 1990 else
1989 { 1991 {
1990 // standard treatment for devices with the dumb embedix frontlight interface 1992 // standard treatment for devices with the dumb embedix frontlight interface
1991 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1993 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1992 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1994 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1993 if ( bright && !bl ) 1995 if ( bright && !bl )
1994 bl = 1; 1996 bl = 1;
1995 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1997 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1996 ::close ( fd ); 1998 ::close ( fd );
1997 } 1999 }
1998 } 2000 }
1999 } 2001 }
2000 else 2002 else
2001 { 2003 {
2002 // special treatment for the OpenZaurus unified interface 2004 // special treatment for the OpenZaurus unified interface
2003 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 2005 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
2004 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 2006 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
2005 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 2007 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
2006 ::close ( fd ); 2008 ::close ( fd );
2007 } 2009 }
2008 } 2010 }
2009 return res; 2011 return res;
2010} 2012}
2011 2013
2012bool Zaurus::suspend ( ) 2014bool Zaurus::suspend ( )
2013{ 2015{
2014 qDebug("ODevice::suspend"); 2016 qDebug("ODevice::suspend");
2015 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 2017 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
2016 return false; 2018 return false;
2017 2019
2018 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 2020 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
2019 return false; 2021 return false;
2020 2022
2021 bool res = false; 2023 bool res = false;
2022 2024
2023 struct timeval tvs, tvn; 2025 struct timeval tvs, tvn;
2024 ::gettimeofday ( &tvs, 0 ); 2026 ::gettimeofday ( &tvs, 0 );
2025 2027
2026 ::sync ( ); // flush fs caches 2028 ::sync ( ); // flush fs caches
2027 res = ( ::system ( "apm --suspend" ) == 0 ); 2029 res = ( ::system ( "apm --suspend" ) == 0 );
2028 2030
2029 // This is needed because the iPAQ apm implementation is asynchronous and we 2031 // This is needed because the iPAQ apm implementation is asynchronous and we
2030 // can not be sure when exactly the device is really suspended 2032 // can not be sure when exactly the device is really suspended