summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_ipaq.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_ipaq.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 6dc1295..b18fd32 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -404,99 +404,98 @@ bool iPAQ::setDisplayBrightness ( int bright )
404 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 404 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
405 res = ( ::write( fd, &buf[0], len ) == 0 ); 405 res = ( ::write( fd, &buf[0], len ) == 0 );
406 ::close( fd ); 406 ::close( fd );
407 } 407 }
408 } else { 408 } else {
409 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 409 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
410 FLITE_IN bl; 410 FLITE_IN bl;
411 bl. mode = 1; 411 bl. mode = 1;
412 bl. pwr = bright ? 1 : 0; 412 bl. pwr = bright ? 1 : 0;
413 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 413 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
414 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 414 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
415 ::close ( fd ); 415 ::close ( fd );
416 } 416 }
417 } 417 }
418 418
419 return res; 419 return res;
420} 420}
421 421
422int iPAQ::displayBrightnessResolution() const 422int iPAQ::displayBrightnessResolution() const
423{ 423{
424 int res = 16; 424 int res = 16;
425 425
426 QDir sysClass( "/sys/class/backlight/" ); 426 QDir sysClass( "/sys/class/backlight/" );
427 sysClass.setFilter(QDir::Dirs); 427 sysClass.setFilter(QDir::Dirs);
428 if ( sysClass.exists() && sysClass.count() > 2 ) { 428 if ( sysClass.exists() && sysClass.count() > 2 ) {
429 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/max_brightness" ); 429 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/max_brightness" );
430 int fd = ::open( sysClassPath, O_RDONLY|O_NONBLOCK ); 430 int fd = ::open( sysClassPath, O_RDONLY|O_NONBLOCK );
431 if ( fd ) { 431 if ( fd ) {
432 char buf[100]; 432 char buf[100];
433 if ( ::read( fd, &buf[0], sizeof buf ) ) 433 if ( ::read( fd, &buf[0], sizeof buf ) )
434 ::sscanf( &buf[0], "%d", &res ); 434 ::sscanf( &buf[0], "%d", &res );
435 ::close( fd ); 435 ::close( fd );
436 } 436 }
437 return res; 437 return res;
438 } 438 }
439 439
440 switch ( model()) { 440 switch ( model()) {
441 case Model_iPAQ_H31xx: 441 case Model_iPAQ_H31xx:
442 case Model_iPAQ_H36xx: 442 case Model_iPAQ_H36xx:
443 case Model_iPAQ_H37xx: 443 case Model_iPAQ_H37xx:
444 return 128; // really 256, but >128 could damage the LCD 444 return 128; // really 256, but >128 could damage the LCD
445 445
446 case Model_iPAQ_H38xx: 446 case Model_iPAQ_H38xx:
447 case Model_iPAQ_H39xx: 447 case Model_iPAQ_H39xx:
448 return 64; 448 return 64;
449 case Model_iPAQ_H5xxx: 449 case Model_iPAQ_H5xxx:
450 case Model_iPAQ_HX4700: 450 case Model_iPAQ_HX4700:
451 case Model_iPAQ_H4xxx: 451 case Model_iPAQ_H4xxx:
452 return 255;
453 case Model_iPAQ_H191x: 452 case Model_iPAQ_H191x:
454 return 7; 453 return 255;
455 case Model_iPAQ_H1940: 454 case Model_iPAQ_H1940:
456 return 44; 455 return 44;
457 default: 456 default:
458 return 2; 457 return 2;
459 } 458 }
460} 459}
461 460
462bool iPAQ::setDisplayStatus ( bool on ) 461bool iPAQ::setDisplayStatus ( bool on )
463{ 462{
464 bool res = false; 463 bool res = false;
465 464
466 QString cmdline; 465 QString cmdline;
467 466
468 QDir sysClass( "/sys/class/lcd/" ); 467 QDir sysClass( "/sys/class/lcd/" );
469 sysClass.setFilter(QDir::Dirs); 468 sysClass.setFilter(QDir::Dirs);
470 if ( sysClass.exists() && sysClass.count() > 2 ) { 469 if ( sysClass.exists() && sysClass.count() > 2 ) {
471 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/power" ); 470 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/power" );
472 int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK ); 471 int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK );
473 if ( fd ) { 472 if ( fd ) {
474 char buf[10]; 473 char buf[10];
475 buf[0] = on ? 0 : 4; 474 buf[0] = on ? 0 : 4;
476 buf[1] = '\0'; 475 buf[1] = '\0';
477 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 476 res = ( ::write( fd, &buf[0], 2 ) == 0 );
478 ::close( fd ); 477 ::close( fd );
479 } 478 }
480 } else { 479 } else {
481 res = OAbstractMobileDevice::setDisplayStatus(on); 480 res = OAbstractMobileDevice::setDisplayStatus(on);
482 } 481 }
483 482
484 return res; 483 return res;
485} 484}
486 485
487bool iPAQ::hasLightSensor() const 486bool iPAQ::hasLightSensor() const
488{ 487{
489 switch (model()) { 488 switch (model()) {
490 case Model_iPAQ_H191x: 489 case Model_iPAQ_H191x:
491 case Model_iPAQ_H22xx: 490 case Model_iPAQ_H22xx:
492 case Model_iPAQ_H4xxx: 491 case Model_iPAQ_H4xxx:
493 return false; 492 return false;
494 default: 493 default:
495 return true; 494 return true;
496 } 495 }
497} 496}
498 497
499int iPAQ::readLightSensor() 498int iPAQ::readLightSensor()
500{ 499{
501 int fd; 500 int fd;
502 int val = -1; 501 int val = -1;