author | mickeyl <mickeyl> | 2005-01-01 19:33:30 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-01 19:33:30 (UTC) |
commit | 5f310dcd91f574c1b34ca99c157c0b93e6ae1e16 (patch) (unidiff) | |
tree | 50157690d75a8f925385a8ef5964b52e22d922ad /libopie2/opiecore/device/odevice_zaurus.cpp | |
parent | a62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a (diff) | |
download | opie-5f310dcd91f574c1b34ca99c157c0b93e6ae1e16.zip opie-5f310dcd91f574c1b34ca99c157c0b93e6ae1e16.tar.gz opie-5f310dcd91f574c1b34ca99c157c0b93e6ae1e16.tar.bz2 |
rewrite backlight stuff
Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 70 |
1 files changed, 25 insertions, 45 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 1894e15..e75e777 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -405,68 +405,50 @@ bool Zaurus::setSoftSuspend ( bool soft ) | |||
405 | } | 405 | } |
406 | 406 | ||
407 | bool Zaurus::setDisplayBrightness( int bright ) | 407 | bool Zaurus::setDisplayBrightness( int bright ) |
408 | { | 408 | { |
409 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 409 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
410 | bool res = false; | 410 | bool res = false; |
411 | int fd; | ||
412 | 411 | ||
413 | if ( bright > 255 ) bright = 255; | 412 | if ( bright > 255 ) bright = 255; |
414 | if ( bright < 0 ) bright = 0; | 413 | if ( bright < 0 ) bright = 0; |
415 | 414 | ||
416 | if ( m_embedix ) | 415 | if ( m_embedix ) |
417 | { | 416 | { |
418 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 417 | int numberOfSteps = displayBrightnessResolution(); |
419 | { | 418 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
420 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | 419 | if ( fd ) |
421 | // special treatment for devices with the corgi backlight interface | ||
422 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | ||
423 | { | 420 | { |
424 | int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); | 421 | int val = ( numberOfSteps * 255 ) / 255; |
425 | char writeCommand[100]; | 422 | res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
426 | const int count = sprintf( writeCommand, "%x\n", value ); | ||
427 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | ||
428 | ::close ( fd ); | 423 | ::close ( fd ); |
429 | } | 424 | } |
430 | return res; | ||
431 | } | 425 | } |
432 | else | 426 | else |
433 | if ( d->m_model == Model_Zaurus_SL6000 ) | ||
434 | { | ||
435 | //qDebug( "using special treatment for devices with the tosa backlight interface" ); | ||
436 | // special treatment for devices with the tosa backlight interface | ||
437 | if (( fd = ::open ( "/proc/driver/fl/tosa-bl", O_WRONLY )) >= 0 ) | ||
438 | { | 427 | { |
439 | int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); | 428 | qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); |
440 | char writeCommand[100]; | ||
441 | const int count = sprintf( writeCommand, "%x\n", value ); | ||
442 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | ||
443 | ::close ( fd ); | ||
444 | } | 429 | } |
445 | return res; | 430 | return res; |
446 | } | 431 | } |
447 | else | 432 | |
433 | bool Zaurus::setDisplayStatus( bool on ) | ||
434 | { | ||
435 | bool res = false; | ||
436 | if ( m_embedix ) | ||
448 | { | 437 | { |
449 | // standard treatment for devices with the dumb embedix frontlight interface | 438 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
450 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 439 | if ( fd ) |
451 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 440 | { |
452 | if ( bright && !bl ) | 441 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
453 | bl = 1; | 442 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
454 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | ||
455 | ::close ( fd ); | 443 | ::close ( fd ); |
456 | } | 444 | } |
457 | } | 445 | } |
458 | } | ||
459 | else | 446 | else |
460 | { | 447 | { |
461 | // special treatment for the OpenZaurus unified interface | 448 | qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); |
462 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | ||
463 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | ||
464 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | ||
465 | ::close ( fd ); | ||
466 | } | ||
467 | } | 449 | } |
468 | return res; | 450 | return res; |
469 | } | 451 | } |
470 | 452 | ||
471 | bool Zaurus::suspend() | 453 | bool Zaurus::suspend() |
472 | { | 454 | { |
@@ -483,18 +465,16 @@ bool Zaurus::suspend() | |||
483 | struct timeval tvs, tvn; | 465 | struct timeval tvs, tvn; |
484 | ::gettimeofday ( &tvs, 0 ); | 466 | ::gettimeofday ( &tvs, 0 ); |
485 | 467 | ||
486 | ::sync(); // flush fs caches | 468 | ::sync(); // flush fs caches |
487 | res = ( ::system ( "apm --suspend" ) == 0 ); | 469 | res = ( ::system ( "apm --suspend" ) == 0 ); |
488 | 470 | ||
489 | // This is needed because the iPAQ apm implementation is asynchronous and we | 471 | // This is needed because the apm implementation is asynchronous and we |
490 | // can not be sure when exactly the device is really suspended | 472 | // can not be sure when exactly the device is really suspended |
491 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | ||
492 | |||
493 | if ( res ) { | 473 | if ( res ) { |
494 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | 474 | do { // Yes, wait 15 seconds. This APM sucks big time. |
495 | ::usleep ( 200 * 1000 ); | 475 | ::usleep ( 200 * 1000 ); |
496 | ::gettimeofday ( &tvn, 0 ); | 476 | ::gettimeofday ( &tvn, 0 ); |
497 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 477 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
498 | } | 478 | } |
499 | 479 | ||
500 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 480 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
@@ -554,31 +534,31 @@ ODirection Zaurus::direction() const | |||
554 | } | 534 | } |
555 | break; | 535 | break; |
556 | case Model_Zaurus_SLA300: | 536 | case Model_Zaurus_SLA300: |
557 | case Model_Zaurus_SLB600: | 537 | case Model_Zaurus_SLB600: |
558 | case Model_Zaurus_SL5500: | 538 | case Model_Zaurus_SL5500: |
559 | case Model_Zaurus_SL5000: | 539 | case Model_Zaurus_SL5000: |
560 | default: | 540 | default: dir = d->m_direction; |
561 | dir = d->m_direction; | ||
562 | break; | 541 | break; |
563 | } | 542 | } |
564 | return dir; | 543 | return dir; |
565 | 544 | ||
566 | } | 545 | } |
567 | 546 | ||
568 | int Zaurus::displayBrightnessResolution() const | 547 | int Zaurus::displayBrightnessResolution() const |
569 | { | 548 | { |
570 | if (m_embedix) | 549 | if (m_embedix) |
571 | { | 550 | { |
572 | if ( d->m_model == Model_Zaurus_SLC7x0 ) return 18; | 551 | int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
573 | if ( d->m_model == Model_Zaurus_SL6000 ) return 18; | 552 | if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 ); |
574 | return 5; | 553 | else return 1; |
575 | } | 554 | } |
576 | else | 555 | else |
577 | { | 556 | { |
578 | return 256; | 557 | qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); |
558 | return 1; | ||
579 | } | 559 | } |
580 | } | 560 | } |
581 | 561 | ||
582 | bool Zaurus::hasHingeSensor() const | 562 | bool Zaurus::hasHingeSensor() const |
583 | { | 563 | { |
584 | return d->m_model == Model_Zaurus_SLC7x0; | 564 | return d->m_model == Model_Zaurus_SLC7x0; |