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) (unidiff)
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) (ignore 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 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; version 2 of the License.
13     ._= =}       : or (at your option) any later version. 12     ._= =}       :
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22:     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29*/ 28*/
30 29
31#include "odevice_zaurus.h" 30#include "odevice_zaurus.h"
32 31
33/* QT */ 32/* QT */
34#include <qapplication.h> 33#include <qapplication.h>
35#include <qfile.h> 34#include <qfile.h>
36#include <qtextstream.h> 35#include <qtextstream.h>
37#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
@@ -111,25 +110,25 @@ struct z_button z_buttons_c700 [] = {
111 "devicebuttons/z_hinge2", 110 "devicebuttons/z_hinge2",
112 "QPE/Rotation", "rotateDefault()",0}, 111 "QPE/Rotation", "rotateDefault()",0},
113 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), 112 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
114 "devicebuttons/z_hinge3", 113 "devicebuttons/z_hinge3",
115 "QPE/Rotation", "rotateDefault()",0}, 114 "QPE/Rotation", "rotateDefault()",0},
116}; 115};
117 116
118// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 117// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
119// class up into individual classes. We would need three classes 118// class up into individual classes. We would need three classes
120// 119//
121// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 120// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
122// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 121// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
123// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000) 122// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100)
124// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) 123// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
125 124
126void Zaurus::init(const QString& cpu_info) 125void Zaurus::init(const QString& cpu_info)
127{ 126{
128 // Set the time to wait until the system is really suspended 127 // Set the time to wait until the system is really suspended
129 // the delta between apm --suspend and sleeping 128 // the delta between apm --suspend and sleeping
130 setAPMTimeOut( 15000 ); 129 setAPMTimeOut( 15000 );
131 130
132 // generic distribution code already scanned /etc/issue at that point - 131 // generic distribution code already scanned /etc/issue at that point -
133 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 132 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
134 if ( d->m_sysverstr.contains( "embedix", false ) ) 133 if ( d->m_sysverstr.contains( "embedix", false ) )
135 { 134 {
@@ -190,24 +189,38 @@ void Zaurus::init(const QString& cpu_info)
190 d->m_modelstr = "Zaurus SL-6000"; 189 d->m_modelstr = "Zaurus SL-6000";
191 } else if ( model == "SHARP Spitz" ) { 190 } else if ( model == "SHARP Spitz" ) {
192 d->m_model = Model_Zaurus_SLC3000; 191 d->m_model = Model_Zaurus_SLC3000;
193 d->m_modelstr = "Zaurus SL-C3000"; 192 d->m_modelstr = "Zaurus SL-C3000";
194 } else if ( model == "SHARP Akita" ) { 193 } else if ( model == "SHARP Akita" ) {
195 d->m_model = Model_Zaurus_SLC1000; 194 d->m_model = Model_Zaurus_SLC1000;
196 d->m_modelstr = "Zaurus SL-C1000"; 195 d->m_modelstr = "Zaurus SL-C1000";
197 } else { 196 } else {
198 d->m_model = Model_Zaurus_SL5500; 197 d->m_model = Model_Zaurus_SL5500;
199 d->m_modelstr = "Unknown Zaurus"; 198 d->m_modelstr = "Unknown Zaurus";
200 } 199 }
201 200
201 // set path to backlight device in kernel 2.6
202 switch ( d->m_model ) {
203 case Model_Zaurus_SLB600: // fallthrough
204 case Model_Zaurus_SL5500:
205 m_backlightdev = "/sys/class/backlight/locomo-backlight/";
206 break;
207 case Model_Zaurus_SL6000:
208 m_backlightdev = "/sys/class/backlight/tosa-bl/";
209 break;
210 default:
211 m_backlightdev = "/sys/class/backlight/corgi-bl/";
212 break;
213 }
214
202 // set initial rotation 215 // set initial rotation
203 switch( d->m_model ) { 216 switch( d->m_model ) {
204 case Model_Zaurus_SL6000: // fallthrough 217 case Model_Zaurus_SL6000: // fallthrough
205 case Model_Zaurus_SLA300: 218 case Model_Zaurus_SLA300:
206 d->m_rotation = Rot0; 219 d->m_rotation = Rot0;
207 break; 220 break;
208 case Model_Zaurus_SLC3000: // fallthrough 221 case Model_Zaurus_SLC3000: // fallthrough
209 case Model_Zaurus_SLC1000: // fallthrough 222 case Model_Zaurus_SLC1000: // fallthrough
210 case Model_Zaurus_SLC7x0: 223 case Model_Zaurus_SLC7x0:
211 d->m_rotation = rotation(); 224 d->m_rotation = rotation();
212 d->m_direction = direction(); 225 d->m_direction = direction();
213 break; 226 break;
@@ -402,25 +415,25 @@ int Zaurus::displayBrightnessResolution() const
402 if (m_embedix) 415 if (m_embedix)
403 { 416 {
404 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 417 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
405 if ( fd ) 418 if ( fd )
406 { 419 {
407 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); 420 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
408 ::close( fd ); 421 ::close( fd );
409 return value ? value : res; 422 return value ? value : res;
410 } 423 }
411 } 424 }
412 else 425 else
413 { 426 {
414 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); 427 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
415 if ( fd ) 428 if ( fd )
416 { 429 {
417 char buf[100]; 430 char buf[100];
418 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 431 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
419 ::close( fd ); 432 ::close( fd );
420 } 433 }
421 } 434 }
422 return res; 435 return res;
423} 436}
424 437
425bool Zaurus::setDisplayBrightness( int bright ) 438bool Zaurus::setDisplayBrightness( int bright )
426{ 439{
@@ -435,25 +448,25 @@ bool Zaurus::setDisplayBrightness( int bright )
435 448
436 if ( m_embedix ) 449 if ( m_embedix )
437 { 450 {
438 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 451 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
439 if ( fd ) 452 if ( fd )
440 { 453 {
441 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 454 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
442 ::close( fd ); 455 ::close( fd );
443 } 456 }
444 } 457 }
445 else 458 else
446 { 459 {
447 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); 460 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
448 if ( fd ) 461 if ( fd )
449 { 462 {
450 char buf[100]; 463 char buf[100];
451 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 464 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
452 res = ( ::write( fd, &buf[0], len ) == 0 ); 465 res = ( ::write( fd, &buf[0], len ) == 0 );
453 ::close( fd ); 466 ::close( fd );
454 } 467 }
455 } 468 }
456 return res; 469 return res;
457} 470}
458 471
459bool Zaurus::setDisplayStatus( bool on ) 472bool Zaurus::setDisplayStatus( bool on )
@@ -462,25 +475,25 @@ bool Zaurus::setDisplayStatus( bool on )
462 if ( m_embedix ) 475 if ( m_embedix )
463 { 476 {
464 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 477 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
465 if ( fd ) 478 if ( fd )
466 { 479 {
467 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 480 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
468 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 481 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
469 ::close ( fd ); 482 ::close ( fd );
470 } 483 }
471 } 484 }
472 else 485 else
473 { 486 {
474 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); 487 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
475 if ( fd ) 488 if ( fd )
476 { 489 {
477 char buf[10]; 490 char buf[10];
478 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 491 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
479 buf[1] = '\0'; 492 buf[1] = '\0';
480 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 493 res = ( ::write( fd, &buf[0], 2 ) == 0 );
481 ::close( fd ); 494 ::close( fd );
482 } 495 }
483 } 496 }
484 return res; 497 return res;
485} 498}
486 499
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 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : or (at your option) any later version. 12     ._= =}       :
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
@@ -116,24 +116,25 @@ class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
116 116
117 virtual bool hasHingeSensor() const; 117 virtual bool hasHingeSensor() const;
118 virtual OHingeStatus readHingeSensor() const; 118 virtual OHingeStatus readHingeSensor() const;
119 119
120 virtual Transformation rotation() const; 120 virtual Transformation rotation() const;
121 virtual ODirection direction() const; 121 virtual ODirection direction() const;
122 virtual bool suspend(); 122 virtual bool suspend();
123 123
124 protected: 124 protected:
125 virtual void buzzer( int snd ); 125 virtual void buzzer( int snd );
126 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 126 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
127 127
128 QString m_backlightdev;
128 OLedState m_leds[1]; 129 OLedState m_leds[1];
129 bool m_embedix; 130 bool m_embedix;
130}; 131};
131 132
132struct z_button { 133struct z_button {
133 Qt::Key code; 134 Qt::Key code;
134 char *utext; 135 char *utext;
135 char *pix; 136 char *pix;
136 char *fpressedservice; 137 char *fpressedservice;
137 char *fpressedaction; 138 char *fpressedaction;
138 char *fheldservice; 139 char *fheldservice;
139 char *fheldaction; 140 char *fheldaction;