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
@@ -1534,75 +1534,75 @@ bool 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;
@@ -1675,60 +1675,60 @@ void Zaurus::initButtons ( )
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)
@@ -1943,64 +1943,66 @@ bool Zaurus::setSoftSuspend ( bool soft )
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 );