summaryrefslogtreecommitdiff
path: root/libopie2/opiecore
Unidiff
Diffstat (limited to 'libopie2/opiecore') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp92
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h20
2 files changed, 45 insertions, 67 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
@@ -410,3 +410,2 @@ bool Zaurus::setDisplayBrightness( int bright )
410 bool res = false; 410 bool res = false;
411 int fd;
412 411
@@ -417,41 +416,9 @@ bool Zaurus::setDisplayBrightness( int bright )
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 {
424 int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
425 char writeCommand[100];
426 const int count = sprintf( writeCommand, "%x\n", value );
427 res = ( ::write ( fd, writeCommand, count ) != -1 );
428 ::close ( fd );
429 }
430 return res;
431 }
432 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 {
439 int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
440 char writeCommand[100];
441 const int count = sprintf( writeCommand, "%x\n", value );
442 res = ( ::write ( fd, writeCommand, count ) != -1 );
443 ::close ( fd );
444 }
445 return res;
446 }
447 else
448 { 420 {
449 // standard treatment for devices with the dumb embedix frontlight interface 421 int val = ( numberOfSteps * 255 ) / 255;
450 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 422 res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
451 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 423 ::close ( fd );
452 if ( bright && !bl )
453 bl = 1;
454 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
455 ::close ( fd );
456 }
457 } 424 }
@@ -460,6 +427,17 @@ bool Zaurus::setDisplayBrightness( int bright )
460 { 427 {
461 // special treatment for the OpenZaurus unified interface 428 qDebug( "ODevice handling for non-embedix kernels not yet implemented" );
462 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 429 }
463 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 430 return res;
464 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 431}
432
433bool Zaurus::setDisplayStatus( bool on )
434{
435 bool res = false;
436 if ( m_embedix )
437 {
438 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
439 if ( fd )
440 {
441 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
442 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
465 ::close ( fd ); 443 ::close ( fd );
@@ -467,4 +445,8 @@ bool Zaurus::setDisplayBrightness( int bright )
467 } 445 }
446 else
447 {
448 qDebug( "ODevice handling for non-embedix kernels not yet implemented" );
449 }
468 return res; 450 return res;
469} 451}
470 452
@@ -488,8 +470,6 @@ bool Zaurus::suspend()
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 );
@@ -543,3 +523,3 @@ ODirection Zaurus::direction() const
543 case Model_Zaurus_SLC7x0: 523 case Model_Zaurus_SLC7x0:
544 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 524 handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK );
545 if (handle == -1) { 525 if (handle == -1) {
@@ -547,3 +527,3 @@ ODirection Zaurus::direction() const
547 } else { 527 } else {
548 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 528 retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION );
549 ::close (handle); 529 ::close (handle);
@@ -559,4 +539,3 @@ ODirection Zaurus::direction() const
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;
@@ -571,5 +550,5 @@ int Zaurus::displayBrightnessResolution() const
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 }
@@ -577,3 +556,4 @@ int Zaurus::displayBrightnessResolution() const
577 { 556 {
578 return 256; 557 qDebug( "ODevice handling for non-embedix kernels not yet implemented" );
558 return 1;
579 } 559 }
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index dc21546..37ab876 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -78,11 +78,8 @@
78// Brightness 78// Brightness
79#define FL_IOCTL_STEP_CONTRAST 100 79#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl"
80 80#define SHARP_FL_IOCTL_ON 1
81#define CORGI_TOSA_BL_IOCTL_ON 1 81#define SHARP_FL_IOCTL_OFF 2
82#define CORGI_TOSA_BL_IOCTL_OFF 2 82#define SHARP_FL_IOCTL_STEP_CONTRAST 100
83#define CORGI_TOSA_BL_IOCTL_STEP_CONTRAST 100 83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
84#define CORGI_TOSA_BL_IOCTL_GET_STEP_CONTRAST 101 84#define SHARP_FL_IOCTL_GET_STEP 102
85#define CORGI_TOSA_BL_IOCTL_GET_STEP 102
86#define CORGI_BL_PROC_DEVICE corgi-bl
87#define TOSA_BL_PROC_DEVICE tosa-bl
88 85
@@ -98,5 +95,6 @@ class Zaurus : public ODevice
98 public: 95 public:
99 virtual bool setSoftSuspend ( bool soft ); 96 virtual bool setSoftSuspend( bool soft );
100 97
101 virtual bool setDisplayBrightness ( int b ); 98 virtual bool setDisplayBrightness( int b );
99 virtual bool setDisplayStatus( bool on );
102 virtual int displayBrightnessResolution() const; 100 virtual int displayBrightnessResolution() const;