summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-01-01 19:33:30 (UTC)
committer mickeyl <mickeyl>2005-01-01 19:33:30 (UTC)
commit5f310dcd91f574c1b34ca99c157c0b93e6ae1e16 (patch) (side-by-side diff)
tree50157690d75a8f925385a8ef5964b52e22d922ad
parenta62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a (diff)
downloadopie-5f310dcd91f574c1b34ca99c157c0b93e6ae1e16.zip
opie-5f310dcd91f574c1b34ca99c157c0b93e6ae1e16.tar.gz
opie-5f310dcd91f574c1b34ca99c157c0b93e6ae1e16.tar.bz2
rewrite backlight stuff
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
@@ -399,108 +399,88 @@ bool Zaurus::setSoftSuspend ( bool soft )
::close ( fd );
}
else
perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
return res;
}
bool Zaurus::setDisplayBrightness( int bright )
{
//qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
bool res = false;
- int fd;
if ( bright > 255 ) bright = 255;
if ( bright < 0 ) bright = 0;
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()
{
qDebug("ODevice::suspend");
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
return false;
bool res = false;
ODevice::sendSuspendmsg();
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync(); // flush fs caches
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 );
} while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
}
QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
return res;
}
Transformation Zaurus::rotation() const
{
@@ -532,59 +512,59 @@ Transformation Zaurus::rotation() const
break;
}
return rot;
}
ODirection Zaurus::direction() const
{
ODirection dir;
int handle = 0;
int retval = 0;
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 )
dir = CCW;
else
dir = CW;
}
break;
case Model_Zaurus_SLA300:
case Model_Zaurus_SLB600:
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
- default:
- dir = d->m_direction;
+ default: dir = d->m_direction;
break;
}
return dir;
}
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;
}
}
bool Zaurus::hasHingeSensor() const
{
return d->m_model == Model_Zaurus_SLC7x0;
}
OHingeStatus Zaurus::readHingeSensor()
{
int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
if (handle == -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
@@ -67,47 +67,45 @@
#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
// Rotation and Power Management
#define SHARP_IOCTL_GET_ROTATION 0x413c
#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
#define APM_EVT_POWER_BUTTON (1 << 0)
// 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 {
namespace Core {
namespace Internal {
class Zaurus : public ODevice
{
protected:
virtual void init(const QString&);
virtual void initButtons();
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;
virtual void playAlarmSound();
virtual void playKeySound();
virtual void playTouchSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList ( OLed led ) const;
virtual OLedState ledState( OLed led ) const;
virtual bool setLedState( OLed led, OLedState st );
virtual bool hasHingeSensor() const;