summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-01-01 19:59:53 (UTC)
committer mickeyl <mickeyl>2005-01-01 19:59:53 (UTC)
commitd4b1226ed820ec06ba07361f31dbb35ce559a4cc (patch) (unidiff)
treed86de5da06a19d5d2a9efd8f1cbc5c90657b0406
parent5f310dcd91f574c1b34ca99c157c0b93e6ae1e16 (diff)
downloadopie-d4b1226ed820ec06ba07361f31dbb35ce559a4cc.zip
opie-d4b1226ed820ec06ba07361f31dbb35ce559a4cc.tar.gz
opie-d4b1226ed820ec06ba07361f31dbb35ce559a4cc.tar.bz2
slightly more correct way to calculate the brightness
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index e75e777..fb23e1d 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -293,257 +293,257 @@ void Zaurus::buzzer( int sound )
293 } 293 }
294 294
295 } 295 }
296#endif 296#endif
297} 297}
298 298
299 299
300void Zaurus::playAlarmSound() 300void Zaurus::playAlarmSound()
301{ 301{
302 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 302 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
303} 303}
304 304
305void Zaurus::playTouchSound() 305void Zaurus::playTouchSound()
306{ 306{
307 buzzer( SHARP_BUZ_TOUCHSOUND ); 307 buzzer( SHARP_BUZ_TOUCHSOUND );
308} 308}
309 309
310void Zaurus::playKeySound() 310void Zaurus::playKeySound()
311{ 311{
312 buzzer( SHARP_BUZ_KEYSOUND ); 312 buzzer( SHARP_BUZ_KEYSOUND );
313} 313}
314 314
315 315
316QValueList <OLed> Zaurus::ledList() const 316QValueList <OLed> Zaurus::ledList() const
317{ 317{
318 QValueList <OLed> vl; 318 QValueList <OLed> vl;
319 vl << Led_Mail; 319 vl << Led_Mail;
320 return vl; 320 return vl;
321} 321}
322 322
323QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 323QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
324{ 324{
325 QValueList <OLedState> vl; 325 QValueList <OLedState> vl;
326 326
327 if ( l == Led_Mail ) 327 if ( l == Led_Mail )
328 vl << Led_Off << Led_On << Led_BlinkSlow; 328 vl << Led_Off << Led_On << Led_BlinkSlow;
329 return vl; 329 return vl;
330} 330}
331 331
332OLedState Zaurus::ledState ( OLed which ) const 332OLedState Zaurus::ledState ( OLed which ) const
333{ 333{
334 if ( which == Led_Mail ) 334 if ( which == Led_Mail )
335 return m_leds [0]; 335 return m_leds [0];
336 else 336 else
337 return Led_Off; 337 return Led_Off;
338} 338}
339 339
340bool Zaurus::setLedState ( OLed which, OLedState st ) 340bool Zaurus::setLedState ( OLed which, OLedState st )
341{ 341{
342 if (!m_embedix) // Currently not supported on non_embedix kernels 342 if (!m_embedix) // Currently not supported on non_embedix kernels
343 return false; 343 return false;
344 344
345 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 345 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
346 346
347 if ( which == Led_Mail ) { 347 if ( which == Led_Mail ) {
348 if ( fd >= 0 ) { 348 if ( fd >= 0 ) {
349 struct sharp_led_status leds; 349 struct sharp_led_status leds;
350 ::memset ( &leds, 0, sizeof( leds )); 350 ::memset ( &leds, 0, sizeof( leds ));
351 leds. which = SHARP_LED_MAIL_EXISTS; 351 leds. which = SHARP_LED_MAIL_EXISTS;
352 bool ok = true; 352 bool ok = true;
353 353
354 switch ( st ) { 354 switch ( st ) {
355 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 355 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
356 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 356 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
357 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 357 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
358 default : ok = false; 358 default : ok = false;
359 } 359 }
360 360
361 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 361 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
362 m_leds [0] = st; 362 m_leds [0] = st;
363 return true; 363 return true;
364 } 364 }
365 } 365 }
366 } 366 }
367 return false; 367 return false;
368} 368}
369 369
370bool Zaurus::setSoftSuspend ( bool soft ) 370bool Zaurus::setSoftSuspend ( bool soft )
371{ 371{
372 if (!m_embedix) { 372 if (!m_embedix) {
373 /* non-Embedix kernels dont have kernel autosuspend */ 373 /* non-Embedix kernels dont have kernel autosuspend */
374 return ODevice::setSoftSuspend( soft ); 374 return ODevice::setSoftSuspend( soft );
375 } 375 }
376 376
377 bool res = false; 377 bool res = false;
378 int fd; 378 int fd;
379 379
380 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 380 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
381 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 381 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
382 382
383 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 383 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
384 384
385 if ( sources >= 0 ) { 385 if ( sources >= 0 ) {
386 if ( soft ) 386 if ( soft )
387 sources &= ~APM_EVT_POWER_BUTTON; 387 sources &= ~APM_EVT_POWER_BUTTON;
388 else 388 else
389 sources |= APM_EVT_POWER_BUTTON; 389 sources |= APM_EVT_POWER_BUTTON;
390 390
391 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 391 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
392 res = true; 392 res = true;
393 else 393 else
394 perror ( "APM_IOCGEVTSRC" ); 394 perror ( "APM_IOCGEVTSRC" );
395 } 395 }
396 else 396 else
397 perror ( "APM_IOCGEVTSRC" ); 397 perror ( "APM_IOCGEVTSRC" );
398 398
399 ::close ( fd ); 399 ::close ( fd );
400 } 400 }
401 else 401 else
402 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 402 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
403 403
404 return res; 404 return res;
405} 405}
406 406
407bool Zaurus::setDisplayBrightness( int bright ) 407bool Zaurus::setDisplayBrightness( int bright )
408{ 408{
409 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 409 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
410 bool res = false; 410 bool res = false;
411 411
412 if ( bright > 255 ) bright = 255; 412 if ( bright > 255 ) bright = 255;
413 if ( bright < 0 ) bright = 0; 413 if ( bright < 0 ) bright = 0;
414 414
415 if ( m_embedix ) 415 if ( m_embedix )
416 { 416 {
417 int numberOfSteps = displayBrightnessResolution(); 417 int numberOfSteps = displayBrightnessResolution();
418 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 418 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
419 if ( fd ) 419 if ( fd )
420 { 420 {
421 int val = ( numberOfSteps * 255 ) / 255; 421 int val = ( bright * numberOfSteps ) / 255;
422 res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 422 res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
423 ::close ( fd ); 423 ::close ( fd );
424 } 424 }
425 } 425 }
426 else 426 else
427 { 427 {
428 qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); 428 qDebug( "ODevice handling for non-embedix kernels not yet implemented" );
429 } 429 }
430 return res; 430 return res;
431} 431}
432 432
433bool Zaurus::setDisplayStatus( bool on ) 433bool Zaurus::setDisplayStatus( bool on )
434{ 434{
435 bool res = false; 435 bool res = false;
436 if ( m_embedix ) 436 if ( m_embedix )
437 { 437 {
438 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 438 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
439 if ( fd ) 439 if ( fd )
440 { 440 {
441 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 441 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
442 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 442 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
443 ::close ( fd ); 443 ::close ( fd );
444 } 444 }
445 } 445 }
446 else 446 else
447 { 447 {
448 qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); 448 qDebug( "ODevice handling for non-embedix kernels not yet implemented" );
449 } 449 }
450 return res; 450 return res;
451} 451}
452 452
453bool Zaurus::suspend() 453bool Zaurus::suspend()
454{ 454{
455 qDebug("ODevice::suspend"); 455 qDebug("ODevice::suspend");
456 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 456 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
457 return false; 457 return false;
458 458
459 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 459 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
460 return false; 460 return false;
461 461
462 bool res = false; 462 bool res = false;
463 ODevice::sendSuspendmsg(); 463 ODevice::sendSuspendmsg();
464 464
465 struct timeval tvs, tvn; 465 struct timeval tvs, tvn;
466 ::gettimeofday ( &tvs, 0 ); 466 ::gettimeofday ( &tvs, 0 );
467 467
468 ::sync(); // flush fs caches 468 ::sync(); // flush fs caches
469 res = ( ::system ( "apm --suspend" ) == 0 ); 469 res = ( ::system ( "apm --suspend" ) == 0 );
470 470
471 // This is needed because the apm implementation is asynchronous and we 471 // This is needed because the apm implementation is asynchronous and we
472 // can not be sure when exactly the device is really suspended 472 // can not be sure when exactly the device is really suspended
473 if ( res ) { 473 if ( res ) {
474 do { // Yes, wait 15 seconds. This APM sucks big time. 474 do { // Yes, wait 15 seconds. This APM sucks big time.
475 ::usleep ( 200 * 1000 ); 475 ::usleep ( 200 * 1000 );
476 ::gettimeofday ( &tvn, 0 ); 476 ::gettimeofday ( &tvn, 0 );
477 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 477 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
478 } 478 }
479 479
480 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 480 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
481 return res; 481 return res;
482} 482}
483 483
484 484
485Transformation Zaurus::rotation() const 485Transformation Zaurus::rotation() const
486{ 486{
487 Transformation rot; 487 Transformation rot;
488 int handle = 0; 488 int handle = 0;
489 int retval = 0; 489 int retval = 0;
490 490
491 switch ( d->m_model ) { 491 switch ( d->m_model ) {
492 case Model_Zaurus_SLC7x0: 492 case Model_Zaurus_SLC7x0:
493 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 493 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
494 if (handle == -1) { 494 if (handle == -1) {
495 return Rot270; 495 return Rot270;
496 } else { 496 } else {
497 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 497 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
498 ::close (handle); 498 ::close (handle);
499 499
500 if (retval == 2 ) 500 if (retval == 2 )
501 rot = Rot0; 501 rot = Rot0;
502 else 502 else
503 rot = Rot270; 503 rot = Rot270;
504 } 504 }
505 break; 505 break;
506 case Model_Zaurus_SLA300: 506 case Model_Zaurus_SLA300:
507 case Model_Zaurus_SLB600: 507 case Model_Zaurus_SLB600:
508 case Model_Zaurus_SL5500: 508 case Model_Zaurus_SL5500:
509 case Model_Zaurus_SL5000: 509 case Model_Zaurus_SL5000:
510 default: 510 default:
511 rot = d->m_rotation; 511 rot = d->m_rotation;
512 break; 512 break;
513 } 513 }
514 514
515 return rot; 515 return rot;
516} 516}
517ODirection Zaurus::direction() const 517ODirection Zaurus::direction() const
518{ 518{
519 ODirection dir; 519 ODirection dir;
520 int handle = 0; 520 int handle = 0;
521 int retval = 0; 521 int retval = 0;
522 switch ( d->m_model ) { 522 switch ( d->m_model ) {
523 case Model_Zaurus_SLC7x0: 523 case Model_Zaurus_SLC7x0:
524 handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); 524 handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK );
525 if (handle == -1) { 525 if (handle == -1) {
526 dir = CW; 526 dir = CW;
527 } else { 527 } else {
528 retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); 528 retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION );
529 ::close (handle); 529 ::close (handle);
530 if (retval == 2 ) 530 if (retval == 2 )
531 dir = CCW; 531 dir = CCW;
532 else 532 else
533 dir = CW; 533 dir = CW;
534 } 534 }
535 break; 535 break;
536 case Model_Zaurus_SLA300: 536 case Model_Zaurus_SLA300:
537 case Model_Zaurus_SLB600: 537 case Model_Zaurus_SLB600:
538 case Model_Zaurus_SL5500: 538 case Model_Zaurus_SL5500:
539 case Model_Zaurus_SL5000: 539 case Model_Zaurus_SL5000:
540 default: dir = d->m_direction; 540 default: dir = d->m_direction;
541 break; 541 break;
542 } 542 }
543 return dir; 543 return dir;
544 544
545} 545}
546 546
547int Zaurus::displayBrightnessResolution() const 547int Zaurus::displayBrightnessResolution() const
548{ 548{
549 if (m_embedix) 549 if (m_embedix)