author | mickeyl <mickeyl> | 2005-01-01 19:33:30 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-01 19:33:30 (UTC) |
commit | 5f310dcd91f574c1b34ca99c157c0b93e6ae1e16 (patch) (side-by-side diff) | |
tree | 50157690d75a8f925385a8ef5964b52e22d922ad | |
parent | a62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a (diff) | |
download | opie-5f310dcd91f574c1b34ca99c157c0b93e6ae1e16.zip opie-5f310dcd91f574c1b34ca99c157c0b93e6ae1e16.tar.gz opie-5f310dcd91f574c1b34ca99c157c0b93e6ae1e16.tar.bz2 |
rewrite backlight stuff
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 70 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 16 |
2 files changed, 32 insertions, 54 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 @@ -409,5 +409,4 @@ bool Zaurus::setDisplayBrightness( int bright ) //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); bool res = false; - int fd; if ( bright > 255 ) bright = 255; @@ -416,53 +415,36 @@ bool Zaurus::setDisplayBrightness( int bright ) if ( m_embedix ) { - if ( d->m_model == Model_Zaurus_SLC7x0 ) - { - //qDebug( "using special treatment for devices with the corgi backlight interface" ); - // special treatment for devices with the corgi backlight interface - if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) + int numberOfSteps = displayBrightnessResolution(); + int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); + if ( fd ) { - int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); - char writeCommand[100]; - const int count = sprintf( writeCommand, "%x\n", value ); - res = ( ::write ( fd, writeCommand, count ) != -1 ); + int val = ( numberOfSteps * 255 ) / 255; + res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); ::close ( fd ); } - return res; } else - if ( d->m_model == Model_Zaurus_SL6000 ) - { - //qDebug( "using special treatment for devices with the tosa backlight interface" ); - // special treatment for devices with the tosa backlight interface - if (( fd = ::open ( "/proc/driver/fl/tosa-bl", O_WRONLY )) >= 0 ) { - int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); - char writeCommand[100]; - const int count = sprintf( writeCommand, "%x\n", value ); - res = ( ::write ( fd, writeCommand, count ) != -1 ); - ::close ( fd ); + qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); } return res; } - else + +bool Zaurus::setDisplayStatus( bool on ) +{ + bool res = false; + if ( m_embedix ) { - // standard treatment for devices with the dumb embedix frontlight interface - if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { - int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus - if ( bright && !bl ) - bl = 1; - res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); + int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); + if ( fd ) + { + int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; + res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); ::close ( fd ); } } - } else { - // special treatment for the OpenZaurus unified interface - #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ - if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { - res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); - ::close ( fd ); - } + qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); } return res; @@ -487,10 +469,8 @@ bool Zaurus::suspend() res = ( ::system ( "apm --suspend" ) == 0 ); - // This is needed because the iPAQ apm implementation is asynchronous and we + // This is needed because the apm implementation is asynchronous and we // can not be sure when exactly the device is really suspended - // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. - if ( res ) { - do { // Yes, wait 15 seconds. This APM bug sucks big time. + do { // Yes, wait 15 seconds. This APM sucks big time. ::usleep ( 200 * 1000 ); ::gettimeofday ( &tvn, 0 ); @@ -558,6 +538,5 @@ ODirection Zaurus::direction() const case Model_Zaurus_SL5500: case Model_Zaurus_SL5000: - default: - dir = d->m_direction; + default: dir = d->m_direction; break; } @@ -570,11 +549,12 @@ int Zaurus::displayBrightnessResolution() const if (m_embedix) { - if ( d->m_model == Model_Zaurus_SLC7x0 ) return 18; - if ( d->m_model == Model_Zaurus_SL6000 ) return 18; - return 5; + int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); + if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 ); + else return 1; } else { - return 256; + qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); + return 1; } } 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 @@ -77,13 +77,10 @@ // Brightness -#define FL_IOCTL_STEP_CONTRAST 100 - -#define CORGI_TOSA_BL_IOCTL_ON 1 -#define CORGI_TOSA_BL_IOCTL_OFF 2 -#define CORGI_TOSA_BL_IOCTL_STEP_CONTRAST 100 -#define CORGI_TOSA_BL_IOCTL_GET_STEP_CONTRAST 101 -#define CORGI_TOSA_BL_IOCTL_GET_STEP 102 -#define CORGI_BL_PROC_DEVICE corgi-bl -#define TOSA_BL_PROC_DEVICE tosa-bl +#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" +#define SHARP_FL_IOCTL_ON 1 +#define SHARP_FL_IOCTL_OFF 2 +#define SHARP_FL_IOCTL_STEP_CONTRAST 100 +#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 +#define SHARP_FL_IOCTL_GET_STEP 102 namespace Opie { @@ -100,4 +97,5 @@ class Zaurus : public ODevice virtual bool setDisplayBrightness ( int b ); + virtual bool setDisplayStatus( bool on ); virtual int displayBrightnessResolution() const; |