summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 7302d2c..b7f3104 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -489,148 +489,159 @@ bool Zaurus::setDisplayBrightness( int bright )
489 if ( bright > 255 ) bright = 255; 489 if ( bright > 255 ) bright = 255;
490 if ( bright < 0 ) bright = 0; 490 if ( bright < 0 ) bright = 0;
491 491
492 int numberOfSteps = displayBrightnessResolution(); 492 int numberOfSteps = displayBrightnessResolution();
493 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 493 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
494 494
495 if ( m_embedix ) 495 if ( m_embedix )
496 { 496 {
497 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 497 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
498 if ( fd ) 498 if ( fd )
499 { 499 {
500 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 500 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
501 ::close( fd ); 501 ::close( fd );
502 } 502 }
503 } 503 }
504 else 504 else
505 { 505 {
506 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); 506 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
507 if ( fd ) 507 if ( fd )
508 { 508 {
509 char buf[100]; 509 char buf[100];
510 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 510 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
511 res = ( ::write( fd, &buf[0], len ) == 0 ); 511 res = ( ::write( fd, &buf[0], len ) == 0 );
512 ::close( fd ); 512 ::close( fd );
513 } 513 }
514 } 514 }
515 return res; 515 return res;
516} 516}
517 517
518bool Zaurus::setDisplayStatus( bool on ) 518bool Zaurus::setDisplayStatus( bool on )
519{ 519{
520 bool res = false; 520 bool res = false;
521 if ( m_embedix ) 521 if ( m_embedix )
522 { 522 {
523 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 523 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
524 if ( fd ) 524 if ( fd )
525 { 525 {
526 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 526 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
527 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 527 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
528 ::close ( fd ); 528 ::close ( fd );
529 } 529 }
530 } 530 }
531 else 531 else
532 { 532 {
533 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); 533 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
534 if ( fd ) 534 if ( fd )
535 { 535 {
536 char buf[10]; 536 char buf[10];
537 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 537 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
538 buf[1] = '\0'; 538 buf[1] = '\0';
539 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 539 res = ( ::write( fd, &buf[0], 2 ) == 0 );
540 ::close( fd ); 540 ::close( fd );
541 } 541 }
542 } 542 }
543 return res; 543 return res;
544} 544}
545 545
546Transformation Zaurus::rotation() const 546Transformation Zaurus::rotation() const
547{ 547{
548 qDebug( "Zaurus::rotation()" ); 548 qDebug( "Zaurus::rotation()" );
549 Transformation rot; 549 Transformation rot;
550 550
551 switch ( d->m_model ) { 551 switch ( d->m_model ) {
552 case Model_Zaurus_SLC3000: // fallthrough 552 case Model_Zaurus_SLC3000: // fallthrough
553 case Model_Zaurus_SLC1000: // fallthrough 553 case Model_Zaurus_SLC1000:
554 {
555 OHingeStatus hs = readHingeSensor();
556 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
557 if ( hs == CASE_PORTRAIT ) rot = Rot0;
558 else if ( hs == CASE_UNKNOWN ) rot = Rot270;
559 else rot = Rot270;
560 }
561 break;
562
563 // SLC7x0 needs a special case here, because we were able to set the W100
564 // hardware default rotation on kernel 2.6 to Rot0
554 case Model_Zaurus_SLC7x0: 565 case Model_Zaurus_SLC7x0:
555 { 566 {
556 OHingeStatus hs = readHingeSensor(); 567 OHingeStatus hs = readHingeSensor();
557 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); 568 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
558 569
559 if ( m_embedix ) 570 if ( m_embedix )
560 { 571 {
561 if ( hs == CASE_PORTRAIT ) rot = Rot0; 572 if ( hs == CASE_PORTRAIT ) rot = Rot0;
562 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 573 else if ( hs == CASE_UNKNOWN ) rot = Rot270;
563 else rot = Rot270; 574 else rot = Rot270;
564 } 575 }
565 else 576 else
566 { 577 {
567 if ( hs == CASE_PORTRAIT ) rot = Rot90; 578 if ( hs == CASE_PORTRAIT ) rot = Rot90;
568 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 579 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
569 else rot = Rot0; 580 else rot = Rot0;
570 } 581 }
571 } 582 }
572 break; 583 break;
573 case Model_Zaurus_SL6000: 584 case Model_Zaurus_SL6000:
574 case Model_Zaurus_SLB600: 585 case Model_Zaurus_SLB600:
575 case Model_Zaurus_SLA300: 586 case Model_Zaurus_SLA300:
576 case Model_Zaurus_SL5500: 587 case Model_Zaurus_SL5500:
577 case Model_Zaurus_SL5000: 588 case Model_Zaurus_SL5000:
578 default: 589 default:
579 rot = d->m_rotation; 590 rot = d->m_rotation;
580 break; 591 break;
581 } 592 }
582 593
583 return rot; 594 return rot;
584} 595}
585ODirection Zaurus::direction() const 596ODirection Zaurus::direction() const
586{ 597{
587 ODirection dir; 598 ODirection dir;
588 599
589 switch ( d->m_model ) { 600 switch ( d->m_model ) {
590 case Model_Zaurus_SLC3000: // fallthrough 601 case Model_Zaurus_SLC3000: // fallthrough
591 case Model_Zaurus_SLC1000: // fallthrough 602 case Model_Zaurus_SLC1000: // fallthrough
592 case Model_Zaurus_SLC7x0: { 603 case Model_Zaurus_SLC7x0: {
593 OHingeStatus hs = readHingeSensor(); 604 OHingeStatus hs = readHingeSensor();
594 if ( hs == CASE_PORTRAIT ) dir = CCW; 605 if ( hs == CASE_PORTRAIT ) dir = CCW;
595 else if ( hs == CASE_UNKNOWN ) dir = CCW; 606 else if ( hs == CASE_UNKNOWN ) dir = CCW;
596 else dir = CW; 607 else dir = CW;
597 } 608 }
598 break; 609 break;
599 case Model_Zaurus_SL6000: 610 case Model_Zaurus_SL6000:
600 case Model_Zaurus_SLA300: 611 case Model_Zaurus_SLA300:
601 case Model_Zaurus_SLB600: 612 case Model_Zaurus_SLB600:
602 case Model_Zaurus_SL5500: 613 case Model_Zaurus_SL5500:
603 case Model_Zaurus_SL5000: 614 case Model_Zaurus_SL5000:
604 default: dir = d->m_direction; 615 default: dir = d->m_direction;
605 break; 616 break;
606 } 617 }
607 return dir; 618 return dir;
608 619
609} 620}
610 621
611bool Zaurus::hasHingeSensor() const 622bool Zaurus::hasHingeSensor() const
612{ 623{
613 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000; 624 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000;
614} 625}
615 626
616OHingeStatus Zaurus::readHingeSensor() const 627OHingeStatus Zaurus::readHingeSensor() const
617{ 628{
618 if (m_embedix) 629 if (m_embedix)
619 { 630 {
620 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 631 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
621 if (handle == -1) 632 if (handle == -1)
622 { 633 {
623 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 634 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
624 return CASE_UNKNOWN; 635 return CASE_UNKNOWN;
625 } 636 }
626 else 637 else
627 { 638 {
628 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 639 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
629 ::close (handle); 640 ::close (handle);
630 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 641 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
631 { 642 {
632 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 643 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
633 return static_cast<OHingeStatus>( retval ); 644 return static_cast<OHingeStatus>( retval );
634 } 645 }
635 else 646 else
636 { 647 {