Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index b22ee70..cbc7a24 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -335,133 +335,96 @@ QValueList <OLedState> Zaurus::ledStateList( OLed l ) const | |||
335 | 335 | ||
336 | if ( l == Led_Mail ) | 336 | if ( l == Led_Mail ) |
337 | vl << Led_Off << Led_On << Led_BlinkSlow; | 337 | vl << Led_Off << Led_On << Led_BlinkSlow; |
338 | return vl; | 338 | return vl; |
339 | } | 339 | } |
340 | 340 | ||
341 | OLedState Zaurus::ledState( OLed which ) const | 341 | OLedState Zaurus::ledState( OLed which ) const |
342 | { | 342 | { |
343 | if ( which == Led_Mail ) | 343 | if ( which == Led_Mail ) |
344 | return m_leds [0]; | 344 | return m_leds [0]; |
345 | else | 345 | else |
346 | return Led_Off; | 346 | return Led_Off; |
347 | } | 347 | } |
348 | 348 | ||
349 | bool Zaurus::setLedState( OLed which, OLedState st ) | 349 | bool Zaurus::setLedState( OLed which, OLedState st ) |
350 | { | 350 | { |
351 | // Currently not supported on non_embedix kernels | 351 | // Currently not supported on non_embedix kernels |
352 | if (!m_embedix) | 352 | if (!m_embedix) |
353 | { | 353 | { |
354 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | 354 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); |
355 | return false; | 355 | return false; |
356 | } | 356 | } |
357 | 357 | ||
358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
359 | 359 | ||
360 | if ( which == Led_Mail ) { | 360 | if ( which == Led_Mail ) { |
361 | if ( fd >= 0 ) { | 361 | if ( fd >= 0 ) { |
362 | struct sharp_led_status leds; | 362 | struct sharp_led_status leds; |
363 | ::memset ( &leds, 0, sizeof( leds )); | 363 | ::memset ( &leds, 0, sizeof( leds )); |
364 | leds. which = SHARP_LED_MAIL_EXISTS; | 364 | leds. which = SHARP_LED_MAIL_EXISTS; |
365 | bool ok = true; | 365 | bool ok = true; |
366 | 366 | ||
367 | switch ( st ) { | 367 | switch ( st ) { |
368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
371 | default : ok = false; | 371 | default : ok = false; |
372 | } | 372 | } |
373 | 373 | ||
374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
375 | m_leds [0] = st; | 375 | m_leds [0] = st; |
376 | return true; | 376 | return true; |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
380 | return false; | 380 | return false; |
381 | } | 381 | } |
382 | 382 | ||
383 | bool Zaurus::setSoftSuspend ( bool soft ) | ||
384 | { | ||
385 | if (!m_embedix) { | ||
386 | /* non-Embedix kernels dont have kernel autosuspend */ | ||
387 | return ODevice::setSoftSuspend( soft ); | ||
388 | } | ||
389 | |||
390 | bool res = false; | ||
391 | int fd; | ||
392 | |||
393 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | ||
394 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | ||
395 | |||
396 | int sources = ::ioctl( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | ||
397 | |||
398 | if ( sources >= 0 ) { | ||
399 | if ( soft ) | ||
400 | sources &= ~APM_EVT_POWER_BUTTON; | ||
401 | else | ||
402 | sources |= APM_EVT_POWER_BUTTON; | ||
403 | |||
404 | if ( ::ioctl( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | ||
405 | res = true; | ||
406 | else | ||
407 | perror ( "APM_IOCGEVTSRC" ); | ||
408 | } | ||
409 | else | ||
410 | perror ( "APM_IOCGEVTSRC" ); | ||
411 | |||
412 | ::close( fd ); | ||
413 | } | ||
414 | else | ||
415 | perror( "/dev/apm_bios or /dev/misc/apm_bios" ); | ||
416 | |||
417 | return res; | ||
418 | } | ||
419 | |||
420 | int Zaurus::displayBrightnessResolution() const | 383 | int Zaurus::displayBrightnessResolution() const |
421 | { | 384 | { |
422 | int res = 1; | 385 | int res = 1; |
423 | if (m_embedix) | 386 | if (m_embedix) |
424 | { | 387 | { |
425 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | 388 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
426 | if ( fd ) | 389 | if ( fd ) |
427 | { | 390 | { |
428 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | 391 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); |
429 | ::close( fd ); | 392 | ::close( fd ); |
430 | return value ? value : res; | 393 | return value ? value : res; |
431 | } | 394 | } |
432 | } | 395 | } |
433 | else | 396 | else |
434 | { | 397 | { |
435 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); | 398 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); |
436 | if ( fd ) | 399 | if ( fd ) |
437 | { | 400 | { |
438 | char buf[100]; | 401 | char buf[100]; |
439 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 402 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
440 | ::close( fd ); | 403 | ::close( fd ); |
441 | } | 404 | } |
442 | } | 405 | } |
443 | return res; | 406 | return res; |
444 | } | 407 | } |
445 | 408 | ||
446 | bool Zaurus::setDisplayBrightness( int bright ) | 409 | bool Zaurus::setDisplayBrightness( int bright ) |
447 | { | 410 | { |
448 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 411 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
449 | bool res = false; | 412 | bool res = false; |
450 | 413 | ||
451 | if ( bright > 255 ) bright = 255; | 414 | if ( bright > 255 ) bright = 255; |
452 | if ( bright < 0 ) bright = 0; | 415 | if ( bright < 0 ) bright = 0; |
453 | 416 | ||
454 | int numberOfSteps = displayBrightnessResolution(); | 417 | int numberOfSteps = displayBrightnessResolution(); |
455 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 418 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
456 | 419 | ||
457 | if ( m_embedix ) | 420 | if ( m_embedix ) |
458 | { | 421 | { |
459 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 422 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
460 | if ( fd ) | 423 | if ( fd ) |
461 | { | 424 | { |
462 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 425 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
463 | ::close( fd ); | 426 | ::close( fd ); |
464 | } | 427 | } |
465 | } | 428 | } |
466 | else | 429 | else |
467 | { | 430 | { |
@@ -495,124 +458,121 @@ bool Zaurus::setDisplayStatus( bool on ) | |||
495 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); | 458 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); |
496 | if ( fd ) | 459 | if ( fd ) |
497 | { | 460 | { |
498 | char buf[10]; | 461 | char buf[10]; |
499 | buf[0] = on ? '1' : '0'; | 462 | buf[0] = on ? '1' : '0'; |
500 | buf[1] = '\0'; | 463 | buf[1] = '\0'; |
501 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 464 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
502 | ::close( fd ); | 465 | ::close( fd ); |
503 | } | 466 | } |
504 | } | 467 | } |
505 | return res; | 468 | return res; |
506 | } | 469 | } |
507 | 470 | ||
508 | bool Zaurus::suspend() | 471 | bool Zaurus::suspend() |
509 | { | 472 | { |
510 | qDebug("ODevice::suspend"); | 473 | qDebug("ODevice::suspend"); |
511 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 474 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
512 | return false; | 475 | return false; |
513 | 476 | ||
514 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 477 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
515 | return false; | 478 | return false; |
516 | 479 | ||
517 | bool res = false; | 480 | bool res = false; |
518 | ODevice::sendSuspendmsg(); | 481 | ODevice::sendSuspendmsg(); |
519 | 482 | ||
520 | struct timeval tvs, tvn; | 483 | struct timeval tvs, tvn; |
521 | ::gettimeofday ( &tvs, 0 ); | 484 | ::gettimeofday ( &tvs, 0 ); |
522 | 485 | ||
523 | ::sync(); // flush fs caches | 486 | ::sync(); // flush fs caches |
524 | res = ( ::system ( "apm --suspend" ) == 0 ); | 487 | res = ( ::system ( "apm --suspend" ) == 0 ); |
525 | 488 | ||
526 | // This is needed because the apm implementation is asynchronous and we | 489 | // This is needed because the apm implementation is asynchronous and we |
527 | // can not be sure when exactly the device is really suspended | 490 | // can not be sure when exactly the device is really suspended |
528 | if ( res ) { | 491 | if ( res ) { |
529 | do { // Yes, wait 15 seconds. This APM sucks big time. | 492 | do { // Yes, wait 15 seconds. This APM sucks big time. |
530 | ::usleep ( 200 * 1000 ); | 493 | ::usleep ( 200 * 1000 ); |
531 | ::gettimeofday ( &tvn, 0 ); | 494 | ::gettimeofday ( &tvn, 0 ); |
532 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 495 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
533 | } | 496 | } |
534 | 497 | ||
535 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 498 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
536 | return res; | 499 | return res; |
537 | } | 500 | } |
538 | 501 | ||
539 | 502 | ||
540 | Transformation Zaurus::rotation() const | 503 | Transformation Zaurus::rotation() const |
541 | { | 504 | { |
542 | Transformation rot; | 505 | Transformation rot; |
543 | int handle = 0; | 506 | |
544 | int retval = 0; | ||
545 | |||
546 | switch ( d->m_model ) { | 507 | switch ( d->m_model ) { |
547 | case Model_Zaurus_SLC3000: // fallthrough | 508 | case Model_Zaurus_SLC3000: // fallthrough |
548 | case Model_Zaurus_SLC7x0: | 509 | case Model_Zaurus_SLC7x0: |
549 | OHingeStatus hs = readHingeSensor(); | 510 | OHingeStatus hs = readHingeSensor(); |
550 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 511 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
551 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 512 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
552 | else rot = Rot270; | 513 | else rot = Rot270; |
553 | break; | 514 | break; |
554 | case Model_Zaurus_SL6000: | 515 | case Model_Zaurus_SL6000: |
555 | case Model_Zaurus_SLB600: | 516 | case Model_Zaurus_SLB600: |
556 | case Model_Zaurus_SLA300: | 517 | case Model_Zaurus_SLA300: |
557 | case Model_Zaurus_SL5500: | 518 | case Model_Zaurus_SL5500: |
558 | case Model_Zaurus_SL5000: | 519 | case Model_Zaurus_SL5000: |
559 | default: | 520 | default: |
560 | rot = d->m_rotation; | 521 | rot = d->m_rotation; |
561 | break; | 522 | break; |
562 | } | 523 | } |
563 | 524 | ||
564 | return rot; | 525 | return rot; |
565 | } | 526 | } |
566 | ODirection Zaurus::direction() const | 527 | ODirection Zaurus::direction() const |
567 | { | 528 | { |
568 | ODirection dir; | 529 | ODirection dir; |
569 | int handle = 0; | 530 | |
570 | int retval = 0; | ||
571 | switch ( d->m_model ) { | 531 | switch ( d->m_model ) { |
572 | case Model_Zaurus_SLC3000: // fallthrough | 532 | case Model_Zaurus_SLC3000: // fallthrough |
573 | case Model_Zaurus_SLC7x0: | 533 | case Model_Zaurus_SLC7x0: |
574 | OHingeStatus hs = readHingeSensor(); | 534 | OHingeStatus hs = readHingeSensor(); |
575 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 535 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
576 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 536 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
577 | else dir = CW; | 537 | else dir = CW; |
578 | break; | 538 | break; |
579 | case Model_Zaurus_SL6000: | 539 | case Model_Zaurus_SL6000: |
580 | case Model_Zaurus_SLA300: | 540 | case Model_Zaurus_SLA300: |
581 | case Model_Zaurus_SLB600: | 541 | case Model_Zaurus_SLB600: |
582 | case Model_Zaurus_SL5500: | 542 | case Model_Zaurus_SL5500: |
583 | case Model_Zaurus_SL5000: | 543 | case Model_Zaurus_SL5000: |
584 | default: dir = d->m_direction; | 544 | default: dir = d->m_direction; |
585 | break; | 545 | break; |
586 | } | 546 | } |
587 | return dir; | 547 | return dir; |
588 | 548 | ||
589 | } | 549 | } |
590 | 550 | ||
591 | bool Zaurus::hasHingeSensor() const | 551 | bool Zaurus::hasHingeSensor() const |
592 | { | 552 | { |
593 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; | 553 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; |
594 | } | 554 | } |
595 | 555 | ||
596 | OHingeStatus Zaurus::readHingeSensor() const | 556 | OHingeStatus Zaurus::readHingeSensor() const |
597 | { | 557 | { |
598 | if (m_embedix) | 558 | if (m_embedix) |
599 | { | 559 | { |
600 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 560 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
601 | if (handle == -1) | 561 | if (handle == -1) |
602 | { | 562 | { |
603 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 563 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
604 | return CASE_UNKNOWN; | 564 | return CASE_UNKNOWN; |
605 | } | 565 | } |
606 | else | 566 | else |
607 | { | 567 | { |
608 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 568 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
609 | ::close (handle); | 569 | ::close (handle); |
610 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 570 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
611 | { | 571 | { |
612 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 572 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
613 | return static_cast<OHingeStatus>( retval ); | 573 | return static_cast<OHingeStatus>( retval ); |
614 | } | 574 | } |
615 | else | 575 | else |
616 | { | 576 | { |
617 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 577 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
618 | return CASE_UNKNOWN; | 578 | return CASE_UNKNOWN; |