summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp71
1 files changed, 29 insertions, 42 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 16ecc27..02b685a 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -399,26 +399,11 @@ bool iPAQ::setDisplayBrightness ( int bright )
- QString cmdline;
-
- switch ( model()) {
- case Model_iPAQ_H191x:
- case Model_iPAQ_H4xxx:
- {
- QDir sysClass( "/sys/class/backlight/pxafb/" );
+ QDir sysClass( "/sys/class/backlight/" );
sysClass.setFilter(QDir::Dirs);
- int fd;
- if ( sysClass.exists() ) {
- QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" );
- fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
- if ( fd ) {
- char buf[10];
- buf[0] = bright ? 0 : 4;
- buf[1] = '\0';
- res = ( ::write( fd, &buf[0], 2 ) == 0 );
- ::close( fd );
- }
- sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" );
- fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
+ if ( sysClass.exists() && sysClass.count() > 2 ) {
+ QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/brightness" );
+ int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK );
if ( fd ) {
char buf[100];
- int len = ::snprintf( &buf[0], sizeof buf, "%d", bright );
+ int val = bright * displayBrightnessResolution() / 255;
+ int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
res = ( ::write( fd, &buf[0], len ) == 0 );
@@ -426,14 +411,3 @@ bool iPAQ::setDisplayBrightness ( int bright )
}
- }
- }
- break;
-
- case Model_iPAQ_HX4700:
- cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/w100fb/brightness" ).arg( bright );
- // No Global::shellQuote as we gurantee it to be sane
- res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
- break;
-
-
- default:
+ } else {
if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
@@ -447,2 +421,3 @@ bool iPAQ::setDisplayBrightness ( int bright )
}
+
return res;
@@ -452,2 +427,18 @@ int iPAQ::displayBrightnessResolution() const
{
+ int res = 16;
+
+ QDir sysClass( "/sys/class/backlight/" );
+ sysClass.setFilter(QDir::Dirs);
+ if ( sysClass.exists() && sysClass.count() > 2 ) {
+ QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/max_brightness" );
+ int fd = ::open( sysClassPath, O_RDONLY|O_NONBLOCK );
+ if ( fd ) {
+ char buf[100];
+ if ( ::read( fd, &buf[0], sizeof buf ) )
+ ::sscanf( &buf[0], "%d", &res );
+ ::close( fd );
+ }
+ return res;
+ }
+
switch ( model()) {
@@ -480,7 +471,6 @@ bool iPAQ::setDisplayStatus ( bool on )
- if ( model() == Model_iPAQ_H191x ) {
- QDir sysClass( "/sys/class/lcd/pxafb/" );
+ QDir sysClass( "/sys/class/lcd/" );
sysClass.setFilter(QDir::Dirs);
- if ( sysClass.exists() ) {
- QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" );
+ if ( sysClass.exists() && sysClass.count() > 2 ) {
+ QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/power" );
int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
@@ -493,10 +483,6 @@ bool iPAQ::setDisplayStatus ( bool on )
}
- }
- return res;
} else {
- return OAbstractMobileDevice::setDisplayStatus(on);
+ res = OAbstractMobileDevice::setDisplayStatus(on);
}
- res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
-
return res;
@@ -508,2 +494,3 @@ bool iPAQ::hasLightSensor() const
case Model_iPAQ_H191x:
+ case Model_iPAQ_H22xx:
case Model_iPAQ_H4xxx: