summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_ipaq.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_ipaq.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp53
1 files changed, 45 insertions, 8 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index e6e3145..63b60a7 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -33,2 +33,3 @@
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qdir.h>
34#include <qfile.h> 35#include <qfile.h>
@@ -381,8 +382,26 @@ bool iPAQ::setDisplayBrightness ( int bright )
381 case Model_iPAQ_H191x: 382 case Model_iPAQ_H191x:
382 if ( !bright ) 383 {
383 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); 384 QDir sysClass( "/sys/class/backlight/pxafb/" );
384 else 385 sysClass.setFilter(QDir::Dirs);
385 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); 386 int fd;
386 // No Global::shellQuote as we gurantee it to be sane 387 if ( sysClass.exists() ) {
387 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 388 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" );
389 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
390 if ( fd ) {
391 char buf[10];
392 buf[0] = bright ? 0 : 4;
393 buf[1] = '\0';
394 res = ( ::write( fd, &buf[0], 2 ) == 0 );
395 ::close( fd );
396 }
397 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" );
398 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
399 if ( fd ) {
400 char buf[100];
401 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright );
402 res = ( ::write( fd, &buf[0], len ) == 0 );
403 ::close( fd );
404 }
405 }
406 }
388 break; 407 break;
@@ -439,3 +458,16 @@ bool iPAQ::setDisplayStatus ( bool on )
439 if ( model() == Model_iPAQ_H191x ) { 458 if ( model() == Model_iPAQ_H191x ) {
440 cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); 459 QDir sysClass( "/sys/class/lcd/pxafb/" );
460 sysClass.setFilter(QDir::Dirs);
461 if ( sysClass.exists() ) {
462 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" );
463 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
464 if ( fd ) {
465 char buf[10];
466 buf[0] = on ? 0 : 4;
467 buf[1] = '\0';
468 res = ( ::write( fd, &buf[0], 2 ) == 0 );
469 ::close( fd );
470 }
471 }
472 return res;
441 } else { 473 } else {
@@ -451,3 +483,8 @@ bool iPAQ::hasLightSensor() const
451{ 483{
452 return true; 484 switch (model()) {
485 case Model_iPAQ_H191x:
486 return false;
487 default:
488 return true;
489 }
453} 490}