summaryrefslogtreecommitdiff
Unidiff
Diffstat (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,73 +1,72 @@
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>
38 37
39/* OPIE */ 38/* OPIE */
40#include <opie2/oinputsystem.h> 39#include <opie2/oinputsystem.h>
41#include <opie2/oresource.h> 40#include <opie2/oresource.h>
42 41
43#include <qpe/config.h> 42#include <qpe/config.h>
44#include <qpe/sound.h> 43#include <qpe/sound.h>
45#include <qpe/qcopenvelope_qws.h> 44#include <qpe/qcopenvelope_qws.h>
46 45
47/* STD */ 46/* STD */
48#include <fcntl.h> 47#include <fcntl.h>
49#include <math.h> 48#include <math.h>
50#include <stdlib.h> 49#include <stdlib.h>
51#include <signal.h> 50#include <signal.h>
52#include <sys/ioctl.h> 51#include <sys/ioctl.h>
53#include <sys/time.h> 52#include <sys/time.h>
54#include <unistd.h> 53#include <unistd.h>
55#ifndef QT_NO_SOUND 54#ifndef QT_NO_SOUND
56#include <linux/soundcard.h> 55#include <linux/soundcard.h>
57#endif 56#endif
58 57
59using namespace Opie::Core; 58using namespace Opie::Core;
60using namespace Opie::Core::Internal; 59using namespace Opie::Core::Internal;
61 60
62struct z_button z_buttons [] = { 61struct z_button z_buttons [] = {
63 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 62 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
64 "devicebuttons/z_calendar", 63 "devicebuttons/z_calendar",
65 "datebook", "nextView()", 64 "datebook", "nextView()",
66 "today", "raise()" }, 65 "today", "raise()" },
67 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 66 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
68 "devicebuttons/z_contact", 67 "devicebuttons/z_contact",
69 "addressbook", "raise()", 68 "addressbook", "raise()",
70 "addressbook", "beamBusinessCard()" }, 69 "addressbook", "beamBusinessCard()" },
71 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 70 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
72 "devicebuttons/z_home", 71 "devicebuttons/z_home",
73 "QPE/Launcher", "home()", 72 "QPE/Launcher", "home()",
@@ -75,175 +74,189 @@ struct z_button z_buttons [] = {
75 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 74 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
76 "devicebuttons/z_menu", 75 "devicebuttons/z_menu",
77 "QPE/TaskBar", "toggleMenu()", 76 "QPE/TaskBar", "toggleMenu()",
78 "QPE/TaskBar", "toggleStartMenu()" }, 77 "QPE/TaskBar", "toggleStartMenu()" },
79 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 78 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
80 "devicebuttons/z_mail", 79 "devicebuttons/z_mail",
81 "opiemail", "raise()", 80 "opiemail", "raise()",
82 "opiemail", "newMail()" }, 81 "opiemail", "newMail()" },
83}; 82};
84 83
85struct z_button z_buttons_c700 [] = { 84struct z_button z_buttons_c700 [] = {
86 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 85 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
87 "devicebuttons/z_calendar", 86 "devicebuttons/z_calendar",
88 "datebook", "nextView()", 87 "datebook", "nextView()",
89 "today", "raise()" }, 88 "today", "raise()" },
90 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 89 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
91 "devicebuttons/z_contact", 90 "devicebuttons/z_contact",
92 "addressbook", "raise()", 91 "addressbook", "raise()",
93 "addressbook", "beamBusinessCard()" }, 92 "addressbook", "beamBusinessCard()" },
94 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 93 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
95 "devicebuttons/z_home", 94 "devicebuttons/z_home",
96 "QPE/Launcher", "home()", 95 "QPE/Launcher", "home()",
97 "buttonsettings", "raise()" }, 96 "buttonsettings", "raise()" },
98 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 97 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
99 "devicebuttons/z_menu", 98 "devicebuttons/z_menu",
100 "QPE/TaskBar", "toggleMenu()", 99 "QPE/TaskBar", "toggleMenu()",
101 "QPE/TaskBar", "toggleStartMenu()" }, 100 "QPE/TaskBar", "toggleStartMenu()" },
102 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 101 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
103 "devicebuttons/z_mail", 102 "devicebuttons/z_mail",
104 "opiemail", "raise()", 103 "opiemail", "raise()",
105 "opiemail", "newMail()" }, 104 "opiemail", "newMail()" },
106 105
107 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), 106 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"),
108 "devicebuttons/z_hinge1", 107 "devicebuttons/z_hinge1",
109 "QPE/Rotation", "rotateDefault()",0}, 108 "QPE/Rotation", "rotateDefault()",0},
110 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), 109 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"),
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 {
136 d->m_vendorstr = "Sharp"; 135 d->m_vendorstr = "Sharp";
137 d->m_vendor = Vendor_Sharp; 136 d->m_vendor = Vendor_Sharp;
138 d->m_systemstr = "Zaurus"; 137 d->m_systemstr = "Zaurus";
139 d->m_system = System_Zaurus; 138 d->m_system = System_Zaurus;
140 m_embedix = true; 139 m_embedix = true;
141 } 140 }
142 else 141 else
143 { 142 {
144 d->m_vendorstr = "OpenZaurus Team"; 143 d->m_vendorstr = "OpenZaurus Team";
145 d->m_systemstr = "OpenZaurus"; 144 d->m_systemstr = "OpenZaurus";
146 d->m_system = System_OpenZaurus; 145 d->m_system = System_OpenZaurus;
147 // sysver already gathered 146 // sysver already gathered
148 147
149 // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one 148 // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one
150 FILE *uname = popen("uname -r", "r"); 149 FILE *uname = popen("uname -r", "r");
151 QFile f; 150 QFile f;
152 QString line; 151 QString line;
153 if ( f.open(IO_ReadOnly, uname) ) { 152 if ( f.open(IO_ReadOnly, uname) ) {
154 QTextStream ts ( &f ); 153 QTextStream ts ( &f );
155 line = ts.readLine(); 154 line = ts.readLine();
156 m_embedix = line.startsWith( "2.4." ); 155 m_embedix = line.startsWith( "2.4." );
157 f.close(); 156 f.close();
158 } 157 }
159 pclose(uname); 158 pclose(uname);
160 } 159 }
161 160
162 // check the Zaurus model 161 // check the Zaurus model
163 QString model; 162 QString model;
164 int loc = cpu_info.find( ":" ); 163 int loc = cpu_info.find( ":" );
165 if ( loc != -1 ) 164 if ( loc != -1 )
166 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 165 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
167 else 166 else
168 model = cpu_info; 167 model = cpu_info;
169 168
170 if ( model == "SHARP Corgi" ) { 169 if ( model == "SHARP Corgi" ) {
171 d->m_model = Model_Zaurus_SLC7x0; 170 d->m_model = Model_Zaurus_SLC7x0;
172 d->m_modelstr = "Zaurus SL-C700"; 171 d->m_modelstr = "Zaurus SL-C700";
173 } else if ( model == "SHARP Shepherd" ) { 172 } else if ( model == "SHARP Shepherd" ) {
174 d->m_model = Model_Zaurus_SLC7x0; 173 d->m_model = Model_Zaurus_SLC7x0;
175 d->m_modelstr = "Zaurus SL-C750"; 174 d->m_modelstr = "Zaurus SL-C750";
176 } else if ( model == "SHARP Husky" ) { 175 } else if ( model == "SHARP Husky" ) {
177 d->m_model = Model_Zaurus_SLC7x0; 176 d->m_model = Model_Zaurus_SLC7x0;
178 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 177 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
179 } else if ( model == "SHARP Boxer" ) { 178 } else if ( model == "SHARP Boxer" ) {
180 d->m_model = Model_Zaurus_SLC7x0; 179 d->m_model = Model_Zaurus_SLC7x0;
181 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 180 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
182 } else if ( model == "SHARP Poodle" ) { 181 } else if ( model == "SHARP Poodle" ) {
183 d->m_model = Model_Zaurus_SLB600; 182 d->m_model = Model_Zaurus_SLB600;
184 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 183 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
185 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 184 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
186 d->m_model = Model_Zaurus_SL5500; 185 d->m_model = Model_Zaurus_SL5500;
187 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 186 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
188 } else if ( model == "SHARP Tosa" ) { 187 } else if ( model == "SHARP Tosa" ) {
189 d->m_model = Model_Zaurus_SL6000; 188 d->m_model = Model_Zaurus_SL6000;
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;
214 case Model_Zaurus_SLB600: // fallthrough 227 case Model_Zaurus_SLB600: // fallthrough
215 case Model_Zaurus_SL5000: // fallthrough 228 case Model_Zaurus_SL5000: // fallthrough
216 case Model_Zaurus_SL5500: // fallthrough 229 case Model_Zaurus_SL5500: // fallthrough
217 default: 230 default:
218 d->m_rotation = Rot270; 231 d->m_rotation = Rot270;
219 break; 232 break;
220 } 233 }
221 m_leds[0] = Led_Off; 234 m_leds[0] = Led_Off;
222 235
223 if ( m_embedix ) 236 if ( m_embedix )
224 qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr ); 237 qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr );
225 else 238 else
226 qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 239 qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
227} 240}
228 241
229void Zaurus::initButtons() 242void Zaurus::initButtons()
230{ 243{
231 if ( d->m_buttons ) 244 if ( d->m_buttons )
232 return; 245 return;
233 246
234 247
235 d->m_buttons = new QValueList <ODeviceButton>; 248 d->m_buttons = new QValueList <ODeviceButton>;
236 249
237 struct z_button * pz_buttons; 250 struct z_button * pz_buttons;
238 int buttoncount; 251 int buttoncount;
239 switch ( d->m_model ) { 252 switch ( d->m_model ) {
240 case Model_Zaurus_SLC3000: // fallthrough 253 case Model_Zaurus_SLC3000: // fallthrough
241 case Model_Zaurus_SLC1000: // fallthrough 254 case Model_Zaurus_SLC1000: // fallthrough
242 case Model_Zaurus_SLC7x0: 255 case Model_Zaurus_SLC7x0:
243 if ( isQWS( ) ) { 256 if ( isQWS( ) ) {
244 addPreHandler(this); // hinge-sensor-handler 257 addPreHandler(this); // hinge-sensor-handler
245 } 258 }
246 pz_buttons = z_buttons_c700; 259 pz_buttons = z_buttons_c700;
247 buttoncount = ARRAY_SIZE(z_buttons_c700); 260 buttoncount = ARRAY_SIZE(z_buttons_c700);
248 break; 261 break;
249 default: 262 default:
@@ -366,157 +379,157 @@ bool Zaurus::setLedState( OLed which, OLedState st )
366{ 379{
367 // Currently not supported on non_embedix kernels 380 // Currently not supported on non_embedix kernels
368 if (!m_embedix) 381 if (!m_embedix)
369 { 382 {
370 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); 383 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
371 return false; 384 return false;
372 } 385 }
373 386
374 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 387 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
375 388
376 if ( which == Led_Mail ) { 389 if ( which == Led_Mail ) {
377 if ( fd >= 0 ) { 390 if ( fd >= 0 ) {
378 struct sharp_led_status leds; 391 struct sharp_led_status leds;
379 ::memset ( &leds, 0, sizeof( leds )); 392 ::memset ( &leds, 0, sizeof( leds ));
380 leds. which = SHARP_LED_MAIL_EXISTS; 393 leds. which = SHARP_LED_MAIL_EXISTS;
381 bool ok = true; 394 bool ok = true;
382 395
383 switch ( st ) { 396 switch ( st ) {
384 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 397 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
385 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 398 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
386 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 399 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
387 default : ok = false; 400 default : ok = false;
388 } 401 }
389 402
390 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 403 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
391 m_leds [0] = st; 404 m_leds [0] = st;
392 return true; 405 return true;
393 } 406 }
394 } 407 }
395 } 408 }
396 return false; 409 return false;
397} 410}
398 411
399int Zaurus::displayBrightnessResolution() const 412int Zaurus::displayBrightnessResolution() const
400{ 413{
401 int res = 1; 414 int res = 1;
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{
427 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 440 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
428 bool res = false; 441 bool res = false;
429 442
430 if ( bright > 255 ) bright = 255; 443 if ( bright > 255 ) bright = 255;
431 if ( bright < 0 ) bright = 0; 444 if ( bright < 0 ) bright = 0;
432 445
433 int numberOfSteps = displayBrightnessResolution(); 446 int numberOfSteps = displayBrightnessResolution();
434 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 447 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
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 )
460{ 473{
461 bool res = false; 474 bool res = false;
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
487Transformation Zaurus::rotation() const 500Transformation Zaurus::rotation() const
488{ 501{
489 qDebug( "Zaurus::rotation()" ); 502 qDebug( "Zaurus::rotation()" );
490 Transformation rot; 503 Transformation rot;
491 504
492 switch ( d->m_model ) { 505 switch ( d->m_model ) {
493 case Model_Zaurus_SLC3000: // fallthrough 506 case Model_Zaurus_SLC3000: // fallthrough
494 case Model_Zaurus_SLC1000: // fallthrough 507 case Model_Zaurus_SLC1000: // fallthrough
495 case Model_Zaurus_SLC7x0: 508 case Model_Zaurus_SLC7x0:
496 { 509 {
497 OHingeStatus hs = readHingeSensor(); 510 OHingeStatus hs = readHingeSensor();
498 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); 511 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
499 512
500 if ( m_embedix ) 513 if ( m_embedix )
501 { 514 {
502 if ( hs == CASE_PORTRAIT ) rot = Rot0; 515 if ( hs == CASE_PORTRAIT ) rot = Rot0;
503 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 516 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
504 else rot = Rot270; 517 else rot = Rot270;
505 } 518 }
506 else 519 else
507 { 520 {
508 if ( hs == CASE_PORTRAIT ) rot = Rot90; 521 if ( hs == CASE_PORTRAIT ) rot = Rot90;
509 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 522 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
510 else rot = Rot0; 523 else rot = Rot0;
511 } 524 }
512 } 525 }
513 break; 526 break;
514 case Model_Zaurus_SL6000: 527 case Model_Zaurus_SL6000:
515 case Model_Zaurus_SLB600: 528 case Model_Zaurus_SLB600:
516 case Model_Zaurus_SLA300: 529 case Model_Zaurus_SLA300:
517 case Model_Zaurus_SL5500: 530 case Model_Zaurus_SL5500:
518 case Model_Zaurus_SL5000: 531 case Model_Zaurus_SL5000:
519 default: 532 default:
520 rot = d->m_rotation; 533 rot = d->m_rotation;
521 break; 534 break;
522 } 535 }
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,60 +1,60 @@
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.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ODEVICE_ZAURUS 30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS 31#define ODEVICE_ZAURUS
32 32
33#include "odevice_abstractmobiledevice.h" 33#include "odevice_abstractmobiledevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38#ifndef ARRAY_SIZE 38#ifndef ARRAY_SIZE
39#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 39#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
40#endif 40#endif
41 41
42// _IO and friends are only defined in kernel headers ... 42// _IO and friends are only defined in kernel headers ...
43#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 43#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
44#define OD_IO(type,number) OD_IOC(0,type,number,0) 44#define OD_IO(type,number) OD_IOC(0,type,number,0)
45#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 45#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
46#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 46#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
47#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 47#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
48 48
49// Audio 49// Audio
50#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 50#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
51 51
52#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 52#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
53#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 53#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
54 54
55#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 55#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
56#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 56#define SHARP_BUZ_KEYSOUND 2 /* key sound */
57#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 57#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
58 58
59#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 59#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
60#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 60#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
@@ -80,65 +80,66 @@
80 80
81// Brightness Embedix 81// Brightness Embedix
82#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" 82#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl"
83#define SHARP_FL_IOCTL_ON 1 83#define SHARP_FL_IOCTL_ON 1
84#define SHARP_FL_IOCTL_OFF 2 84#define SHARP_FL_IOCTL_OFF 2
85#define SHARP_FL_IOCTL_STEP_CONTRAST 100 85#define SHARP_FL_IOCTL_STEP_CONTRAST 100
86#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 86#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
87#define SHARP_FL_IOCTL_GET_STEP 102 87#define SHARP_FL_IOCTL_GET_STEP 102
88 88
89// Vesa Standard 89// Vesa Standard
90#define FB_BLANK_UNBLANK 0 90#define FB_BLANK_UNBLANK 0
91#define FB_BLANK_POWERDOWN 4 91#define FB_BLANK_POWERDOWN 4
92 92
93namespace Opie { 93namespace Opie {
94namespace Core { 94namespace Core {
95namespace Internal { 95namespace Internal {
96 96
97class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter 97class Zaurus : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
98{ 98{
99 protected: 99 protected:
100 virtual void init(const QString&); 100 virtual void init(const QString&);
101 virtual void initButtons(); 101 virtual void initButtons();
102 102
103 public: 103 public:
104 virtual bool setDisplayBrightness( int b ); 104 virtual bool setDisplayBrightness( int b );
105 virtual bool setDisplayStatus( bool on ); 105 virtual bool setDisplayStatus( bool on );
106 virtual int displayBrightnessResolution() const; 106 virtual int displayBrightnessResolution() const;
107 107
108 virtual void playAlarmSound(); 108 virtual void playAlarmSound();
109 virtual void playKeySound(); 109 virtual void playKeySound();
110 virtual void playTouchSound(); 110 virtual void playTouchSound();
111 111
112 virtual QValueList <OLed> ledList() const; 112 virtual QValueList <OLed> ledList() const;
113 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 113 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
114 virtual OLedState ledState( OLed led ) const; 114 virtual OLedState ledState( OLed led ) const;
115 virtual bool setLedState( OLed led, OLedState st ); 115 virtual bool setLedState( OLed led, OLedState st );
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;
140}; 141};
141} 142}
142} 143}
143} 144}
144#endif 145#endif