summaryrefslogtreecommitdiff
path: root/libopie2
authoraquadran <aquadran>2006-06-09 08:27:01 (UTC)
committer aquadran <aquadran>2006-06-09 08:27:01 (UTC)
commitb06b849f271079b0dd5d3419ad1162232ff4a9f5 (patch) (unidiff)
treedfa7d602169ff414ee76f37c400ac3d2eff801d2 /libopie2
parentab1422b3e7df8644d6df2519f5ef5b5c831e3965 (diff)
downloadopie-b06b849f271079b0dd5d3419ad1162232ff4a9f5.zip
opie-b06b849f271079b0dd5d3419ad1162232ff4a9f5.tar.gz
opie-b06b849f271079b0dd5d3419ad1162232ff4a9f5.tar.bz2
changed access method for lcd sys params of ipaq h191x and mypal a716 based on Slavek Banko patch
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp53
-rw-r--r--libopie2/opiecore/device/odevice_mypal.cpp55
2 files changed, 79 insertions, 29 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
@@ -28,12 +28,13 @@
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qdir.h>
34#include <qfile.h> 35#include <qfile.h>
35#include <qtextstream.h> 36#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
37 38
38/* OPIE */ 39/* OPIE */
39#include <qpe/config.h> 40#include <qpe/config.h>
@@ -376,18 +377,36 @@ bool iPAQ::setDisplayBrightness ( int bright )
376 bright = 0; 377 bright = 0;
377 378
378 QString cmdline; 379 QString cmdline;
379 380
380 switch ( model()) { 381 switch ( model()) {
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;
389 408
390 case Model_iPAQ_HX4700: 409 case Model_iPAQ_HX4700:
391 cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/w100fb/brightness" ).arg( bright ); 410 cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/w100fb/brightness" ).arg( bright );
392 // No Global::shellQuote as we gurantee it to be sane 411 // No Global::shellQuote as we gurantee it to be sane
393 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 412 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
@@ -434,25 +453,43 @@ bool iPAQ::setDisplayStatus ( bool on )
434{ 453{
435 bool res = false; 454 bool res = false;
436 455
437 QString cmdline; 456 QString cmdline;
438 457
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 {
442 return OAbstractMobileDevice::setDisplayStatus(on); 474 return OAbstractMobileDevice::setDisplayStatus(on);
443 } 475 }
444 476
445 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 477 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
446 478
447 return res; 479 return res;
448} 480}
449 481
450bool iPAQ::hasLightSensor() const 482bool 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}
454 491
455int iPAQ::readLightSensor() 492int iPAQ::readLightSensor()
456{ 493{
457 int fd; 494 int fd;
458 int val = -1; 495 int val = -1;
diff --git a/libopie2/opiecore/device/odevice_mypal.cpp b/libopie2/opiecore/device/odevice_mypal.cpp
index 7e1245a..7eb8d1d 100644
--- a/libopie2/opiecore/device/odevice_mypal.cpp
+++ b/libopie2/opiecore/device/odevice_mypal.cpp
@@ -28,12 +28,13 @@
28*/ 28*/
29 29
30#include "odevice_mypal.h" 30#include "odevice_mypal.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qdir.h>
34#include <qfile.h> 35#include <qfile.h>
35#include <qtextstream.h> 36#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
37 38
38/* OPIE */ 39/* OPIE */
39#include <qpe/config.h> 40#include <qpe/config.h>
@@ -203,25 +204,33 @@ bool MyPal::setDisplayBrightness ( int bright )
203 204
204 if ( bright > 255 ) 205 if ( bright > 255 )
205 bright = 255; 206 bright = 255;
206 if ( bright < 0 ) 207 if ( bright < 0 )
207 bright = 0; 208 bright = 0;
208 209
209 QString cmdline; 210 QDir sysClass( "/sys/class/backlight/pxafb/" );
210 211 sysClass.setFilter(QDir::Dirs);
211 switch ( model()) { 212 int fd;
212 case Model_MyPal_716: 213 if ( sysClass.exists() ) {
213 if ( !bright ) 214 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" );
214 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); 215 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
215 else 216 if ( fd ) {
216 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); 217 char buf[10];
217 // No Global::shellQuote as we gurantee it to be sane 218 buf[0] = bright ? 0 : 4;
218 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 219 buf[1] = '\0';
219 break; 220 res = ( ::write( fd, &buf[0], 2 ) == 0 );
220 default: 221 ::close( fd );
221 res = OAbstractMobileDevice::setDisplayBrightness(bright); 222 }
223 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" );
224 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
225 if ( fd ) {
226 char buf[100];
227 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright );
228 res = ( ::write( fd, &buf[0], len ) == 0 );
229 ::close( fd );
230 }
222 } 231 }
223 232
224 return res; 233 return res;
225} 234}
226 235
227int MyPal::displayBrightnessResolution() const 236int MyPal::displayBrightnessResolution() const
@@ -235,18 +244,22 @@ int MyPal::displayBrightnessResolution() const
235} 244}
236 245
237bool MyPal::setDisplayStatus ( bool on ) 246bool MyPal::setDisplayStatus ( bool on )
238{ 247{
239 bool res = false; 248 bool res = false;
240 249
241 QString cmdline; 250 QDir sysClass( "/sys/class/lcd/" );
242 251 sysClass.setFilter(QDir::Dirs);
243 if ( model() == Model_MyPal_716 ) { 252 if ( sysClass.exists() ) {
244 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" ); 253 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" );
245 } else { 254 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
246 return OAbstractMobileDevice::setDisplayStatus(on); 255 if ( fd ) {
256 char buf[10];
257 buf[0] = on ? 0 : 4;
258 buf[1] = '\0';
259 res = ( ::write( fd, &buf[0], 2 ) == 0 );
260 ::close( fd );
261 }
247 } 262 }
248 263
249 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
250
251 return res; 264 return res;
252} 265}