summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (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
@@ -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,56 +415,39 @@ 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 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 );
- }
- 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 );
- }
- return res;
- }
- else
+ int numberOfSteps = displayBrightnessResolution();
+ int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
+ if ( fd )
{
- // 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 );
- ::close ( fd );
- }
+ int val = ( numberOfSteps * 255 ) / 255;
+ res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 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 );
+ qDebug( "ODevice handling for non-embedix kernels not yet implemented" );
+ }
+ return res;
+}
+
+bool Zaurus::setDisplayStatus( bool on )
+{
+ bool res = false;
+ if ( m_embedix )
+ {
+ 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
+ {
+ qDebug( "ODevice handling for non-embedix kernels not yet implemented" );
+ }
return res;
-}
+}
bool Zaurus::suspend()
@@ -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 );
@@ -542,9 +522,9 @@ ODirection Zaurus::direction() const
switch ( d->m_model ) {
case Model_Zaurus_SLC7x0:
- handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
+ handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK );
if (handle == -1) {
dir = CW;
} else {
- retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
+ retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION );
::close (handle);
if (retval == 2 )
@@ -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 {
@@ -97,7 +94,8 @@ class Zaurus : public ODevice
public:
- virtual bool setSoftSuspend ( bool soft );
+ virtual bool setSoftSuspend( bool soft );
- virtual bool setDisplayBrightness ( int b );
+ virtual bool setDisplayBrightness( int b );
+ virtual bool setDisplayStatus( bool on );
virtual int displayBrightnessResolution() const;