summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index a59e799..7377965 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -135,474 +135,487 @@ void Zaurus::init(const QString& cpu_info)
135 // generic distribution code already scanned /etc/issue at that point - 135 // generic distribution code already scanned /etc/issue at that point -
136 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 136 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
137 if ( d->m_sysverstr.contains( "embedix", false ) ) 137 if ( d->m_sysverstr.contains( "embedix", false ) )
138 { 138 {
139 d->m_vendorstr = "Sharp"; 139 d->m_vendorstr = "Sharp";
140 d->m_vendor = Vendor_Sharp; 140 d->m_vendor = Vendor_Sharp;
141 d->m_systemstr = "Zaurus"; 141 d->m_systemstr = "Zaurus";
142 d->m_system = System_Zaurus; 142 d->m_system = System_Zaurus;
143 m_embedix = true; 143 m_embedix = true;
144 } 144 }
145 else 145 else
146 { 146 {
147 d->m_vendorstr = "OpenZaurus Team"; 147 d->m_vendorstr = "OpenZaurus Team";
148 d->m_systemstr = "OpenZaurus"; 148 d->m_systemstr = "OpenZaurus";
149 d->m_system = System_OpenZaurus; 149 d->m_system = System_OpenZaurus;
150 // sysver already gathered 150 // sysver already gathered
151 151
152 // OpenZaurus sometimes uses the embedix kernel, check if this is one 152 // OpenZaurus sometimes uses the embedix kernel, check if this is one
153 FILE *uname = popen("uname -r", "r"); 153 FILE *uname = popen("uname -r", "r");
154 QFile f; 154 QFile f;
155 QString line; 155 QString line;
156 if ( f.open(IO_ReadOnly, uname) ) { 156 if ( f.open(IO_ReadOnly, uname) ) {
157 QTextStream ts ( &f ); 157 QTextStream ts ( &f );
158 line = ts. readLine(); 158 line = ts. readLine();
159 int loc = line. find ( "embedix" ); 159 int loc = line. find ( "embedix" );
160 if ( loc != -1 ) 160 if ( loc != -1 )
161 m_embedix = true; 161 m_embedix = true;
162 else 162 else
163 m_embedix = false; 163 m_embedix = false;
164 f.close(); 164 f.close();
165 } 165 }
166 pclose(uname); 166 pclose(uname);
167 } 167 }
168 168
169 // check the Zaurus model 169 // check the Zaurus model
170 QString model; 170 QString model;
171 int loc = cpu_info.find( ":" ); 171 int loc = cpu_info.find( ":" );
172 if ( loc != -1 ) 172 if ( loc != -1 )
173 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 173 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
174 else 174 else
175 model = cpu_info; 175 model = cpu_info;
176 176
177 if ( model == "SHARP Corgi" ) { 177 if ( model == "SHARP Corgi" ) {
178 d->m_model = Model_Zaurus_SLC7x0; 178 d->m_model = Model_Zaurus_SLC7x0;
179 d->m_modelstr = "Zaurus SL-C700"; 179 d->m_modelstr = "Zaurus SL-C700";
180 } else if ( model == "SHARP Shepherd" ) { 180 } else if ( model == "SHARP Shepherd" ) {
181 d->m_model = Model_Zaurus_SLC7x0; 181 d->m_model = Model_Zaurus_SLC7x0;
182 d->m_modelstr = "Zaurus SL-C750"; 182 d->m_modelstr = "Zaurus SL-C750";
183 } else if ( model == "SHARP Husky" ) { 183 } else if ( model == "SHARP Husky" ) {
184 d->m_model = Model_Zaurus_SLC7x0; 184 d->m_model = Model_Zaurus_SLC7x0;
185 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 185 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
186 } else if ( model == "SHARP Boxer" ) { 186 } else if ( model == "SHARP Boxer" ) {
187 d->m_model = Model_Zaurus_SLC7x0; 187 d->m_model = Model_Zaurus_SLC7x0;
188 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 188 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
189 } else if ( model == "SHARP Poodle" ) { 189 } else if ( model == "SHARP Poodle" ) {
190 d->m_model = Model_Zaurus_SLB600; 190 d->m_model = Model_Zaurus_SLB600;
191 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 191 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
192 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 192 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
193 d->m_model = Model_Zaurus_SL5500; 193 d->m_model = Model_Zaurus_SL5500;
194 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 194 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
195 } else if ( model == "SHARP Tosa" ) { 195 } else if ( model == "SHARP Tosa" ) {
196 d->m_model = Model_Zaurus_SL6000; 196 d->m_model = Model_Zaurus_SL6000;
197 d->m_modelstr = "Zaurus SL-6000"; 197 d->m_modelstr = "Zaurus SL-6000";
198 } else if ( model == "SHARP Spitz" ) { 198 } else if ( model == "SHARP Spitz" ) {
199 d->m_model = Model_Zaurus_SLC3000; 199 d->m_model = Model_Zaurus_SLC3000;
200 d->m_modelstr = "Zaurus SL-C3000"; 200 d->m_modelstr = "Zaurus SL-C3000";
201 } else { 201 } else {
202 d->m_model = Model_Zaurus_SL5500; 202 d->m_model = Model_Zaurus_SL5500;
203 d->m_modelstr = "Unknown Zaurus"; 203 d->m_modelstr = "Unknown Zaurus";
204 } 204 }
205 205
206 // set initial rotation 206 // set initial rotation
207 switch( d->m_model ) { 207 switch( d->m_model ) {
208 case Model_Zaurus_SL6000: // fallthrough 208 case Model_Zaurus_SL6000: // fallthrough
209 case Model_Zaurus_SLA300: 209 case Model_Zaurus_SLA300:
210 d->m_rotation = Rot0; 210 d->m_rotation = Rot0;
211 break; 211 break;
212 case Model_Zaurus_SLC3000: // fallthrough 212 case Model_Zaurus_SLC3000: // fallthrough
213 case Model_Zaurus_SLC7x0: 213 case Model_Zaurus_SLC7x0:
214 d->m_rotation = rotation(); 214 d->m_rotation = rotation();
215 d->m_direction = direction(); 215 d->m_direction = direction();
216 break; 216 break;
217 case Model_Zaurus_SLB600: // fallthrough 217 case Model_Zaurus_SLB600: // fallthrough
218 case Model_Zaurus_SL5000: // fallthrough 218 case Model_Zaurus_SL5000: // fallthrough
219 case Model_Zaurus_SL5500: // fallthrough 219 case Model_Zaurus_SL5500: // fallthrough
220 default: 220 default:
221 d->m_rotation = Rot270; 221 d->m_rotation = Rot270;
222 break; 222 break;
223 } 223 }
224 m_leds[0] = Led_Off; 224 m_leds[0] = Led_Off;
225 225
226 if ( m_embedix ) 226 if ( m_embedix )
227 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); 227 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr );
228 else 228 else
229 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 229 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
230} 230}
231 231
232void Zaurus::initButtons() 232void Zaurus::initButtons()
233{ 233{
234 if ( d->m_buttons ) 234 if ( d->m_buttons )
235 return; 235 return;
236 236
237 d->m_buttons = new QValueList <ODeviceButton>; 237 d->m_buttons = new QValueList <ODeviceButton>;
238 238
239 struct z_button * pz_buttons; 239 struct z_button * pz_buttons;
240 int buttoncount; 240 int buttoncount;
241 switch ( d->m_model ) { 241 switch ( d->m_model ) {
242 case Model_Zaurus_SLC3000: // fallthrough 242 case Model_Zaurus_SLC3000: // fallthrough
243 case Model_Zaurus_SLC7x0: 243 case Model_Zaurus_SLC7x0:
244 pz_buttons = z_buttons_c700; 244 pz_buttons = z_buttons_c700;
245 buttoncount = ARRAY_SIZE(z_buttons_c700); 245 buttoncount = ARRAY_SIZE(z_buttons_c700);
246 break; 246 break;
247 default: 247 default:
248 pz_buttons = z_buttons; 248 pz_buttons = z_buttons;
249 buttoncount = ARRAY_SIZE(z_buttons); 249 buttoncount = ARRAY_SIZE(z_buttons);
250 break; 250 break;
251 } 251 }
252 252
253 for ( int i = 0; i < buttoncount; i++ ) { 253 for ( int i = 0; i < buttoncount; i++ ) {
254 struct z_button *zb = pz_buttons + i; 254 struct z_button *zb = pz_buttons + i;
255 ODeviceButton b; 255 ODeviceButton b;
256 256
257 b.setKeycode( zb->code ); 257 b.setKeycode( zb->code );
258 b.setUserText( QObject::tr( "Button", zb->utext )); 258 b.setUserText( QObject::tr( "Button", zb->utext ));
259 b.setPixmap( Resource::loadPixmap( zb->pix )); 259 b.setPixmap( Resource::loadPixmap( zb->pix ));
260 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 260 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
261 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 261 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
262 d->m_buttons->append( b ); 262 d->m_buttons->append( b );
263 } 263 }
264 264
265 reloadButtonMapping(); 265 reloadButtonMapping();
266} 266}
267 267
268 268
269 269
270typedef struct sharp_led_status { 270typedef struct sharp_led_status {
271 int which; /* select which LED status is wanted. */ 271 int which; /* select which LED status is wanted. */
272 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 272 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
273} sharp_led_status; 273} sharp_led_status;
274 274
275void Zaurus::buzzer( int sound ) 275void Zaurus::buzzer( int sound )
276{ 276{
277#ifndef QT_NO_SOUND 277#ifndef QT_NO_SOUND
278 Sound *snd = 0; 278 Sound *snd = 0;
279 279
280 // All devices except SL5500 have a DSP device 280 // All devices except SL5500 have a DSP device
281 if ( d->m_model != Model_Zaurus_SL5000 281 if ( d->m_model != Model_Zaurus_SL5000
282 && d->m_model != Model_Zaurus_SL5500 ) { 282 && d->m_model != Model_Zaurus_SL5500 ) {
283 283
284 switch ( sound ){ 284 switch ( sound ){
285 case SHARP_BUZ_TOUCHSOUND: { 285 case SHARP_BUZ_TOUCHSOUND: {
286 static Sound touch_sound("touchsound"); 286 static Sound touch_sound("touchsound");
287 snd = &touch_sound; 287 snd = &touch_sound;
288 } 288 }
289 break; 289 break;
290 case SHARP_BUZ_KEYSOUND: { 290 case SHARP_BUZ_KEYSOUND: {
291 static Sound key_sound( "keysound" ); 291 static Sound key_sound( "keysound" );
292 snd = &key_sound; 292 snd = &key_sound;
293 } 293 }
294 break; 294 break;
295 case SHARP_BUZ_SCHEDULE_ALARM: 295 case SHARP_BUZ_SCHEDULE_ALARM:
296 default: { 296 default: {
297 static Sound alarm_sound("alarm"); 297 static Sound alarm_sound("alarm");
298 snd = &alarm_sound; 298 snd = &alarm_sound;
299 } 299 }
300 break; 300 break;
301 } 301 }
302 } 302 }
303 303
304 // If a soundname is defined, we expect that this device has 304 // If a soundname is defined, we expect that this device has
305 // sound capabilities.. Otherwise we expect to have the buzzer 305 // sound capabilities.. Otherwise we expect to have the buzzer
306 // device.. 306 // device..
307 if ( snd && snd->isFinished() ){ 307 if ( snd && snd->isFinished() ){
308 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 308 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
309 snd->play(); 309 snd->play();
310 } else if( !snd ) { 310 } else if( !snd ) {
311 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 311 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
312 312
313 if ( fd >= 0 ) { 313 if ( fd >= 0 ) {
314 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 314 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
315 ::close ( fd ); 315 ::close ( fd );
316 } 316 }
317 317
318 } 318 }
319#endif 319#endif
320} 320}
321 321
322 322
323void Zaurus::playAlarmSound() 323void Zaurus::playAlarmSound()
324{ 324{
325 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 325 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
326} 326}
327 327
328void Zaurus::playTouchSound() 328void Zaurus::playTouchSound()
329{ 329{
330 buzzer( SHARP_BUZ_TOUCHSOUND ); 330 buzzer( SHARP_BUZ_TOUCHSOUND );
331} 331}
332 332
333void Zaurus::playKeySound() 333void Zaurus::playKeySound()
334{ 334{
335 buzzer( SHARP_BUZ_KEYSOUND ); 335 buzzer( SHARP_BUZ_KEYSOUND );
336} 336}
337 337
338 338
339QValueList <OLed> Zaurus::ledList() const 339QValueList <OLed> Zaurus::ledList() const
340{ 340{
341 QValueList <OLed> vl; 341 QValueList <OLed> vl;
342 vl << Led_Mail; 342 vl << Led_Mail;
343 return vl; 343 return vl;
344} 344}
345 345
346QValueList <OLedState> Zaurus::ledStateList( OLed l ) const 346QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
347{ 347{
348 QValueList <OLedState> vl; 348 QValueList <OLedState> vl;
349 349
350 if ( l == Led_Mail ) 350 if ( l == Led_Mail )
351 vl << Led_Off << Led_On << Led_BlinkSlow; 351 vl << Led_Off << Led_On << Led_BlinkSlow;
352 return vl; 352 return vl;
353} 353}
354 354
355OLedState Zaurus::ledState( OLed which ) const 355OLedState Zaurus::ledState( OLed which ) const
356{ 356{
357 if ( which == Led_Mail ) 357 if ( which == Led_Mail )
358 return m_leds [0]; 358 return m_leds [0];
359 else 359 else
360 return Led_Off; 360 return Led_Off;
361} 361}
362 362
363bool Zaurus::setLedState( OLed which, OLedState st ) 363bool Zaurus::setLedState( OLed which, OLedState st )
364{ 364{
365 // Currently not supported on non_embedix kernels 365 // Currently not supported on non_embedix kernels
366 if (!m_embedix) 366 if (!m_embedix)
367 { 367 {
368 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); 368 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
369 return false; 369 return false;
370 } 370 }
371 371
372 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 372 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
373 373
374 if ( which == Led_Mail ) { 374 if ( which == Led_Mail ) {
375 if ( fd >= 0 ) { 375 if ( fd >= 0 ) {
376 struct sharp_led_status leds; 376 struct sharp_led_status leds;
377 ::memset ( &leds, 0, sizeof( leds )); 377 ::memset ( &leds, 0, sizeof( leds ));
378 leds. which = SHARP_LED_MAIL_EXISTS; 378 leds. which = SHARP_LED_MAIL_EXISTS;
379 bool ok = true; 379 bool ok = true;
380 380
381 switch ( st ) { 381 switch ( st ) {
382 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 382 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
383 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 383 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
384 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 384 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
385 default : ok = false; 385 default : ok = false;
386 } 386 }
387 387
388 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 388 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
389 m_leds [0] = st; 389 m_leds [0] = st;
390 return true; 390 return true;
391 } 391 }
392 } 392 }
393 } 393 }
394 return false; 394 return false;
395} 395}
396 396
397int Zaurus::displayBrightnessResolution() const 397int Zaurus::displayBrightnessResolution() const
398{ 398{
399 int res = 1; 399 int res = 1;
400 if (m_embedix) 400 if (m_embedix)
401 { 401 {
402 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 402 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
403 if ( fd ) 403 if ( fd )
404 { 404 {
405 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); 405 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
406 ::close( fd ); 406 ::close( fd );
407 return value ? value : res; 407 return value ? value : res;
408 } 408 }
409 } 409 }
410 else 410 else
411 { 411 {
412 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); 412 int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK );
413 if ( fd ) 413 if ( fd )
414 { 414 {
415 char buf[100]; 415 char buf[100];
416 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 416 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
417 ::close( fd ); 417 ::close( fd );
418 } 418 }
419 } 419 }
420 return res; 420 return res;
421} 421}
422 422
423bool Zaurus::setDisplayBrightness( int bright ) 423bool Zaurus::setDisplayBrightness( int bright )
424{ 424{
425 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 425 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
426 bool res = false; 426 bool res = false;
427 427
428 if ( bright > 255 ) bright = 255; 428 if ( bright > 255 ) bright = 255;
429 if ( bright < 0 ) bright = 0; 429 if ( bright < 0 ) bright = 0;
430 430
431 int numberOfSteps = displayBrightnessResolution(); 431 int numberOfSteps = displayBrightnessResolution();
432 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 432 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
433 433
434 if ( m_embedix ) 434 if ( m_embedix )
435 { 435 {
436 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 436 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
437 if ( fd ) 437 if ( fd )
438 { 438 {
439 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 439 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
440 ::close( fd ); 440 ::close( fd );
441 } 441 }
442 } 442 }
443 else 443 else
444 { 444 {
445 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); 445 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK );
446 if ( fd ) 446 if ( fd )
447 { 447 {
448 char buf[100]; 448 char buf[100];
449 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 449 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
450 res = ( ::write( fd, &buf[0], len ) == 0 ); 450 res = ( ::write( fd, &buf[0], len ) == 0 );
451 ::close( fd ); 451 ::close( fd );
452 } 452 }
453 } 453 }
454 return res; 454 return res;
455} 455}
456 456
457bool Zaurus::setDisplayStatus( bool on ) 457bool Zaurus::setDisplayStatus( bool on )
458{ 458{
459 bool res = false; 459 bool res = false;
460 if ( m_embedix ) 460 if ( m_embedix )
461 { 461 {
462 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 462 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
463 if ( fd ) 463 if ( fd )
464 { 464 {
465 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 465 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
466 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 466 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
467 ::close ( fd ); 467 ::close ( fd );
468 } 468 }
469 } 469 }
470 else 470 else
471 { 471 {
472 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); 472 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
473 if ( fd ) 473 if ( fd )
474 { 474 {
475 char buf[10]; 475 char buf[10];
476 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 476 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
477 buf[1] = '\0'; 477 buf[1] = '\0';
478 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 478 res = ( ::write( fd, &buf[0], 2 ) == 0 );
479 ::close( fd ); 479 ::close( fd );
480 } 480 }
481 } 481 }
482 return res; 482 return res;
483} 483}
484 484
485bool Zaurus::suspend() 485bool Zaurus::suspend()
486{ 486{
487 qDebug("ODevice::suspend"); 487 qDebug("ODevice::suspend");
488 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 488 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
489 return false; 489 return false;
490 490
491 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 491 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
492 return false; 492 return false;
493 493
494 bool res = false; 494 bool res = false;
495 ODevice::sendSuspendmsg(); 495 ODevice::sendSuspendmsg();
496 496
497 struct timeval tvs, tvn; 497 struct timeval tvs, tvn;
498 ::gettimeofday ( &tvs, 0 ); 498 ::gettimeofday ( &tvs, 0 );
499 499
500 ::sync(); // flush fs caches 500 ::sync(); // flush fs caches
501 res = ( ::system ( "apm --suspend" ) == 0 ); 501 res = ( ::system ( "apm --suspend" ) == 0 );
502 502
503 // This is needed because the apm implementation is asynchronous and we 503 // This is needed because the apm implementation is asynchronous and we
504 // can not be sure when exactly the device is really suspended 504 // can not be sure when exactly the device is really suspended
505 if ( res ) { 505 if ( res ) {
506 do { // Yes, wait 15 seconds. This APM sucks big time. 506 do { // Yes, wait 15 seconds. This APM sucks big time.
507 ::usleep ( 200 * 1000 ); 507 ::usleep ( 200 * 1000 );
508 ::gettimeofday ( &tvn, 0 ); 508 ::gettimeofday ( &tvn, 0 );
509 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 509 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
510 } 510 }
511 511
512 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 512 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
513 return res; 513 return res;
514} 514}
515 515
516 516
517Transformation Zaurus::rotation() const 517Transformation Zaurus::rotation() const
518{ 518{
519 qDebug( "Zaurus::rotation()" );
519 Transformation rot; 520 Transformation rot;
520 521
521 switch ( d->m_model ) { 522 switch ( d->m_model ) {
522 case Model_Zaurus_SLC3000: // fallthrough 523 case Model_Zaurus_SLC3000: // fallthrough
523 case Model_Zaurus_SLC7x0: { 524 case Model_Zaurus_SLC7x0:
524 OHingeStatus hs = readHingeSensor(); 525 {
526 OHingeStatus hs = readHingeSensor();
527 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
528
529 if ( m_embedix )
530 {
525 if ( hs == CASE_PORTRAIT ) rot = Rot0; 531 if ( hs == CASE_PORTRAIT ) rot = Rot0;
526 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 532 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
527 else rot = Rot270; 533 else rot = Rot270;
528 } 534 }
535 else
536 {
537 if ( hs == CASE_PORTRAIT ) rot = Rot270;
538 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
539 else rot = Rot0;
540 }
541 }
529 break; 542 break;
530 case Model_Zaurus_SL6000: 543 case Model_Zaurus_SL6000:
531 case Model_Zaurus_SLB600: 544 case Model_Zaurus_SLB600:
532 case Model_Zaurus_SLA300: 545 case Model_Zaurus_SLA300:
533 case Model_Zaurus_SL5500: 546 case Model_Zaurus_SL5500:
534 case Model_Zaurus_SL5000: 547 case Model_Zaurus_SL5000:
535 default: 548 default:
536 rot = d->m_rotation; 549 rot = d->m_rotation;
537 break; 550 break;
538 } 551 }
539 552
540 return rot; 553 return rot;
541} 554}
542ODirection Zaurus::direction() const 555ODirection Zaurus::direction() const
543{ 556{
544 ODirection dir; 557 ODirection dir;
545 558
546 switch ( d->m_model ) { 559 switch ( d->m_model ) {
547 case Model_Zaurus_SLC3000: // fallthrough 560 case Model_Zaurus_SLC3000: // fallthrough
548 case Model_Zaurus_SLC7x0: { 561 case Model_Zaurus_SLC7x0: {
549 OHingeStatus hs = readHingeSensor(); 562 OHingeStatus hs = readHingeSensor();
550 if ( hs == CASE_PORTRAIT ) dir = CCW; 563 if ( hs == CASE_PORTRAIT ) dir = CCW;
551 else if ( hs == CASE_UNKNOWN ) dir = CCW; 564 else if ( hs == CASE_UNKNOWN ) dir = CCW;
552 else dir = CW; 565 else dir = CW;
553 } 566 }
554 break; 567 break;
555 case Model_Zaurus_SL6000: 568 case Model_Zaurus_SL6000:
556 case Model_Zaurus_SLA300: 569 case Model_Zaurus_SLA300:
557 case Model_Zaurus_SLB600: 570 case Model_Zaurus_SLB600:
558 case Model_Zaurus_SL5500: 571 case Model_Zaurus_SL5500:
559 case Model_Zaurus_SL5000: 572 case Model_Zaurus_SL5000:
560 default: dir = d->m_direction; 573 default: dir = d->m_direction;
561 break; 574 break;
562 } 575 }
563 return dir; 576 return dir;
564 577
565} 578}
566 579
567bool Zaurus::hasHingeSensor() const 580bool Zaurus::hasHingeSensor() const
568{ 581{
569 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; 582 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
570} 583}
571 584
572OHingeStatus Zaurus::readHingeSensor() const 585OHingeStatus Zaurus::readHingeSensor() const
573{ 586{
574 if (m_embedix) 587 if (m_embedix)
575 { 588 {
576 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 589 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
577 if (handle == -1) 590 if (handle == -1)
578 { 591 {
579 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 592 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
580 return CASE_UNKNOWN; 593 return CASE_UNKNOWN;
581 } 594 }
582 else 595 else
583 { 596 {
584 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 597 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
585 ::close (handle); 598 ::close (handle);
586 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 599 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
587 { 600 {
588 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 601 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
589 return static_cast<OHingeStatus>( retval ); 602 return static_cast<OHingeStatus>( retval );
590 } 603 }
591 else 604 else
592 { 605 {
593 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 606 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
594 return CASE_UNKNOWN; 607 return CASE_UNKNOWN;
595 } 608 }
596 } 609 }
597 } 610 }
598 else 611 else
599 { 612 {
600 // corgi keyboard is event source 0 in OZ kernel 2.6 613 // corgi keyboard is event source 0 in OZ kernel 2.6
601 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); 614 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" );
602 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; 615 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE;
603 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; 616 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT;
604 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; 617 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED;
605 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 618 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
606 return CASE_UNKNOWN; 619 return CASE_UNKNOWN;
607 } 620 }
608} 621}