summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2005-06-09 09:14:22 (UTC)
committer mickeyl <mickeyl>2005-06-09 09:14:22 (UTC)
commit9a4b3a90fdd4ac0288034657d4818e3d10ed0193 (patch) (side-by-side diff)
treeb65dc74dce17f4f709242753152b53767bb1a4fc /libopie2
parent15978c2609cc29d2eb2b21922dd52627015889c1 (diff)
downloadopie-9a4b3a90fdd4ac0288034657d4818e3d10ed0193.zip
opie-9a4b3a90fdd4ac0288034657d4818e3d10ed0193.tar.gz
opie-9a4b3a90fdd4ac0288034657d4818e3d10ed0193.tar.bz2
add support for the linux 2.6 backlight interface on tosa, poodle, and collie
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp65
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h5
2 files changed, 42 insertions, 28 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 1742100..21d2342 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,37 +1,36 @@
/*
-                 This file is part of the Opie Project
-
- Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
+                 This file is part of the Opie Project
+              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
=.
.=l.
-           .>+-=
- _;:,     .>    :=|. This program is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This program is distributed in the hope that
-     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
- : ..    .:,     . . . without even the implied warranty of
-    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
-  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.=       =       ; Library General Public License for more
-++=   -.     .`     .: details.
-:     =  ...= . :.=-
- -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
-    --        :-=` this library; see the file COPYING.LIB.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; version 2 of the License.
+     ._= =}       :
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_zaurus.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
@@ -111,25 +110,25 @@ struct z_button z_buttons_c700 [] = {
"devicebuttons/z_hinge2",
"QPE/Rotation", "rotateDefault()",0},
{ Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
"devicebuttons/z_hinge3",
"QPE/Rotation", "rotateDefault()",0},
};
// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
// class up into individual classes. We would need three classes
//
// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
-// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000)
+// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100)
// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
void Zaurus::init(const QString& cpu_info)
{
// Set the time to wait until the system is really suspended
// the delta between apm --suspend and sleeping
setAPMTimeOut( 15000 );
// generic distribution code already scanned /etc/issue at that point -
// embedix releases contain "Embedix <version> | Linux for Embedded Devices"
if ( d->m_sysverstr.contains( "embedix", false ) )
{
@@ -190,24 +189,38 @@ void Zaurus::init(const QString& cpu_info)
d->m_modelstr = "Zaurus SL-6000";
} else if ( model == "SHARP Spitz" ) {
d->m_model = Model_Zaurus_SLC3000;
d->m_modelstr = "Zaurus SL-C3000";
} else if ( model == "SHARP Akita" ) {
d->m_model = Model_Zaurus_SLC1000;
d->m_modelstr = "Zaurus SL-C1000";
} else {
d->m_model = Model_Zaurus_SL5500;
d->m_modelstr = "Unknown Zaurus";
}
+ // set path to backlight device in kernel 2.6
+ switch ( d->m_model ) {
+ case Model_Zaurus_SLB600: // fallthrough
+ case Model_Zaurus_SL5500:
+ m_backlightdev = "/sys/class/backlight/locomo-backlight/";
+ break;
+ case Model_Zaurus_SL6000:
+ m_backlightdev = "/sys/class/backlight/tosa-bl/";
+ break;
+ default:
+ m_backlightdev = "/sys/class/backlight/corgi-bl/";
+ break;
+ }
+
// set initial rotation
switch( d->m_model ) {
case Model_Zaurus_SL6000: // fallthrough
case Model_Zaurus_SLA300:
d->m_rotation = Rot0;
break;
case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC1000: // fallthrough
case Model_Zaurus_SLC7x0:
d->m_rotation = rotation();
d->m_direction = direction();
break;
@@ -402,25 +415,25 @@ int Zaurus::displayBrightnessResolution() const
if (m_embedix)
{
int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
if ( fd )
{
int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
::close( fd );
return value ? value : res;
}
}
else
{
- int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK );
+ int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
if ( fd )
{
char buf[100];
if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
::close( fd );
}
}
return res;
}
bool Zaurus::setDisplayBrightness( int bright )
{
@@ -435,25 +448,25 @@ bool Zaurus::setDisplayBrightness( int bright )
if ( m_embedix )
{
int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
if ( fd )
{
res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
::close( fd );
}
}
else
{
- int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK );
+ int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
if ( fd )
{
char buf[100];
int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
res = ( ::write( fd, &buf[0], len ) == 0 );
::close( fd );
}
}
return res;
}
bool Zaurus::setDisplayStatus( bool on )
@@ -462,25 +475,25 @@ bool Zaurus::setDisplayStatus( bool on )
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
{
- int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
+ int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
if ( fd )
{
char buf[10];
buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
buf[1] = '\0';
res = ( ::write( fd, &buf[0], 2 ) == 0 );
::close( fd );
}
}
return res;
}
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index 4250356..4314aff 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,24 +1,24 @@
/*
                This file is part of the Opie Project
              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
+ - .   .-<_>     .<> Foundation; version 2 of the License.
+     ._= =}       :
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
@@ -116,24 +116,25 @@ class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
virtual bool hasHingeSensor() const;
virtual OHingeStatus readHingeSensor() const;
virtual Transformation rotation() const;
virtual ODirection direction() const;
virtual bool suspend();
protected:
virtual void buzzer( int snd );
virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
+ QString m_backlightdev;
OLedState m_leds[1];
bool m_embedix;
};
struct z_button {
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;